Tiny event emitter for Go
eventEmitter := nanoevent.New()
unsubscribe := eventEmitter.On("event", func(message string) {
fmt.Println(message)
})
eventEmitter.Emit("event", "Hello Go!") // Prints Hello Go
unsubscribe()
eventEmitter.Emit("event", "Hi Go!") // Prints nothing
func New() *EventEmitter
New creates a new EventEmitter.
func (eventEmitter *EventEmitter) On(event string, listener listenerFunc) func()
On subscribes a listener to an event.
Returns unsubscribe function that can be used to remove subscribed listener.
func (eventEmitter *EventEmitter) Emit(event string, args ...interface{})
Emit emits an event to the listeners.
MIT