-
Notifications
You must be signed in to change notification settings - Fork 41
/
defaults.go
49 lines (38 loc) · 1.09 KB
/
defaults.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
package trigger
import "reflect"
type Trigger interface {
On(event string, task interface{}) error
Fire(event string, params ...interface{}) ([]reflect.Value, error)
FireBackground(event string, params ...interface{}) (chan []reflect.Value, error)
Clear(event string) error
ClearEvents()
HasEvent(event string) bool
Events() []string
EventCount() int
}
var defaultTrigger = New()
// Default global trigger options.
func On(event string, task interface{}) error {
return defaultTrigger.On(event, task)
}
func Fire(event string, params ...interface{}) ([]reflect.Value, error) {
return defaultTrigger.Fire(event, params...)
}
func FireBackground(event string, params ...interface{}) (chan []reflect.Value, error) {
return defaultTrigger.FireBackground(event, params...)
}
func Clear(event string) error {
return defaultTrigger.Clear(event)
}
func ClearEvents() {
defaultTrigger.ClearEvents()
}
func HasEvent(event string) bool {
return defaultTrigger.HasEvent(event)
}
func Events() []string {
return defaultTrigger.Events()
}
func EventCount() int {
return defaultTrigger.EventCount()
}