-
Notifications
You must be signed in to change notification settings - Fork 46
/
message.go
63 lines (52 loc) · 1.96 KB
/
message.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
const (
MessageCardSelected = "MessageCardSelected"
MessageCardDeselected = "MessageCardDeselected"
MessageCardResizeCompleted = "MessageCardResizeCompleted"
MessageCardResizeStart = "MessageCardResizeStart"
MessageCardDeleted = "MessageCardDeleted"
MessageCardRestored = "MessageCardRestored"
MessageCardMoveStack = "MessageCardMoveStack"
MessageContentSwitched = "MessageContentSwitched"
MessageThemeChange = "MessageThemeChange"
MessageUndoRedo = "MessageUndoRedo"
MessageVolumeChange = "MessageVolumeChange"
MessageStacksUpdated = "MessageStacksUpdated"
MessageCollisionGridResized = "MessageCollisionGridResized"
MessageLinkCreated = "MessageLinkCreated"
MessageLinkDeleted = "MessageLinkDeleted"
MessagePageChanged = "MessagePageChanged"
MessageRenderTextureRefresh = "MessageRenderTextureRefresh"
MessageProjectLoadingAllCardsCreated = "MessageProjectLoadingAllCardsCreated"
MessageProjectLoaded = "MessageProjectLoaded"
// MessageCardDeserialized = "MessageCardDeserialized"
)
type Message struct {
Type string
ID interface{}
Data interface{}
}
func NewMessage(messageType string, id interface{}, data interface{}) *Message {
return &Message{
Type: messageType,
ID: id,
Data: data,
}
}
// Dispatcher simply calls functions when any project (not just the current one) changes; this is used to do things only when necessary, rather than constantly.
type Dispatcher struct {
Functions []func()
}
func NewDispatcher() *Dispatcher {
return &Dispatcher{
Functions: []func(){},
}
}
func (md *Dispatcher) Run() {
for _, f := range md.Functions {
f()
}
}
func (md *Dispatcher) Register(function func()) {
md.Functions = append(md.Functions, function)
}