Eventable
To make module Eventable add function GetEventFuncs() to your main.go
.
.
.
func (m module) GetEventFuncs() []eather.Fire {
return eventFuncs
}
var eventFuncs = []eather.Fire{
eather.Fire{Call: "added", Func: added},
eather.Fire{Call: "removed", Func: removed},
}
var added = func(data ...interface{}) {
fmt.Println(data)
time.Sleep(2 * time.Second)
fmt.Println("Running event after added")
}
var removed = func(data ...interface{}) {
fmt.Println(data)
time.Sleep(2 * time.Second)
fmt.Println("Running event after removed")
}
.
.
.And add to module.xml listeners for this events
Now your functions added can be triggered by calling eather.GetEvents().Emmit("test_added", map[string]interface{}{"code": "test_code"})
Last updated
Was this helpful?