-
Notifications
You must be signed in to change notification settings - Fork 0
/
event_definition.go
32 lines (29 loc) · 1015 Bytes
/
event_definition.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
package cyclecmd
// Event is an interface that defines the behavior of the custom events
// that the User can define themselves.
//
// Event expects the following method to be implemented by all events:
//
// Behavior:
// - `Handle(token string) error` : it expects the token that is associated with the event
type Event interface {
Handle(token string) error
}
// EventInformation stores the event itself but also the event name that was given to the custom event.
type EventInformation struct {
// Name of the event
EventName string
// The event instance itself
Event Event
}
// EventHistoryEntry stores the event and the event name but also the token that triggered the event.
// This is especially useful for the DefaultEvent since that event gets triggered by every token
// that is not already registered with another event.
type EventHistoryEntry struct {
// Token is the same as event trigger
Token string
// The name of the event
EventName string
// The event instance itself
Event Event
}