Skip to content

go-zoox/eventemitter

Repository files navigation

EventEmitter - a simple event emitter

PkgGoDev Build Status Go Report Card Coverage Status GitHub issues Release

Installation

To install the package, run:

go get github.com/go-zoox/eventemitter

Getting Started

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()
}

License

GoZoox is released under the MIT License.

About

Simple Event Emitter

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages