Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrRunning = errors.New("event handler is already running")
ErrRunning is returned when trying to run a *Handler that is already running.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
A Handler asynchronously handles published events.
var bus event.Bus h := handler.New(bus) event.HandleWith(h, func(evt event.Of[FooData]) {...}, "foo") event.HandleWith(h, func(evt event.Of[BarData]) {...}, "bar") errs, err := h.Run(context.TODO())
func (*Handler) Context ¶
Context returns the context that was passed to h.Run(). If h.Run() has not been called yet, nil is returned.
func (*Handler) RegisterEventHandler ¶
RegisterEventHandler registers the handler for the given event. Events must be registered before h.Run() is called. events that are registered after h.Run() has been called, won't be handled.
Click to show internal directories.
Click to hide internal directories.