JonasHiltl / emit

Minimal generic event emitter

Repository from Github https://github.comJonasHiltl/emitRepository from Github https://github.comJonasHiltl/emit

Emit

Minimal event emitter using channels.

  • Type Safe: built on generics
  • Batching: timeout and size

Installation

go get github.com/jonashiltl/emit

Usage

e := new(emit.Emitter) // or &emit.Emmiter{}

emit.On(e, func(batch []MyEvent) {
    fmt.Println(batch)
}, WithBatchSize(10), WithTimeout(10*time.Second))

emit.Emit(e, MyEvent{})

Inspired by mint

About

Minimal generic event emitter

License:MIT License


Languages

Language:Go 100.0%