To install the package, run:
go get github.com/go-zoox/eventemitter
import (
"testing"
"github.com/go-zoox/eventemitter"
)
func main(t *testing.T) {
e := eventemitter.New()
count := 0
e.On("send.notify", eventemitter.HandleFunc(func(payload any) {
count++
t.Log("send.notify", payload)
}))
e.Start()
wg := &sync.WaitGroup{}
for i := 0; i < 10; i++ {
index := i
wg.Add(1)
go func() {
e.Emit("send.notify", index)
wg.Done()
}()
}
wg.Wait()
}
GoZoox is released under the MIT License.