Skip to content
/ events Public

A fast event framework for firing and consuming events across borders

License

Notifications You must be signed in to change notification settings

tsatke/events

Repository files navigation

Events

A small dispatcher framework for Go.



How to use

Go get it with

go get github.com/TimSatke/events

First, define your custom events.

const (
	EventExample uint16 = iota
	EventGreeting
	EventGoodbye
)

Second, create a dispatcher.

disp := events.NewDispatcher()
disp.RegisterFunc(EventGreeting, func(evt events.Event) {
	// evt.Type == EventGreeting
	fmt.Printf("Hello, %v!\n", evt.Data)
})

Third, fire an event.

evtGreeting := events.Event{
    Type: EventGreeting,
    Data: "World",
}
disp.Fire(evtGreeting)

Have a look at the examples.

About

A fast event framework for firing and consuming events across borders

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages