Documentation
¶
Overview ¶
Package eventbus provides a typed, in-process event bus modeled on Cordis. Emit broadcasts sequentially, Bail stops at the first matching result, and Serial collects results in registration order. Waterfall dispatch lives in pkg/waterfall. Retain and call the disposer returned by On during cleanup.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bus ¶
Bus is a concurrency-safe event channel with ordered listeners. The zero value is ready to use. Listener updates copy the registration list so dispatch can read a stable snapshot without allocating. This favors workloads that dispatch more often than they register or remove listeners.
func (*Bus[T, R]) Bail ¶
Bail returns the first result for which shouldShort returns true. If no result matches, it returns the zero value and false.
func (*Bus[T, R]) Emit ¶
func (b *Bus[T, R]) Emit(payload T)
Emit invokes all listeners in registration order and ignores their results.
type Listener ¶
Listener receives a payload and returns a result. Emit ignores the result; Bail and Serial use it for short-circuiting and aggregation, respectively.