-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
31 lines (26 loc) · 803 Bytes
/
main.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
package main
import (
"fmt"
"github.com/asheeshrana/event/event"
)
func main() {
eventService := event.GetInstance()
startEvent := eventService.CreateEvent("StartEvent")
startEvent.SetSourceName("Main")
endEvent := eventService.CreateEvent("EndEvent")
endEvent.SetSourceName("Main")
listenerInfo := &event.DefaultListenerInfo{}
listenerInfo.SetName("GenericListener")
listenerInfo.SetCallback(listenerInfo.DefaultCallback)
listenerInfo.SetEventNameMap(map[string]bool{
"StartEvent": true,
"EndEvent": true,
})
eventService.RegisterListener(listenerInfo)
eventService.TriggerEventSync(startEvent)
fmt.Println("I am in the middle doing processing...")
eventService.TriggerEventSync(endEvent)
}
func eventCallBack(e event.Event) {
fmt.Println("Received Event " + e.GetName())
}