Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrListenerNil listener is nil ErrListenerNil = errors.New("listener is nil") // ErrEventNil event is nil ErrEventNil = errors.New("event is nil") // ErrBusClosed bus was closed ErrBusClosed = errors.New("bus was closed") // ErrEventTypeInvalid event type is invalid ErrEventTypeInvalid = errors.New("event type is invalid") // ErrListenerIncomparable listener is incomparable ErrListenerIncomparable = errors.New("listener is incomparable") )
Functions ¶
This section is empty.
Types ¶
type Bus ¶
type Bus interface { // On adds a Listener to the Event bus. On(e Event, lis Listener) error // Prepend adds the Listener to the beginning of the listeners. Prepend(e Event, lis Listener) error // Once adds a one-time Listener to the Event bus. Once(e Event, lis Listener) error // PrependOnce adds a one-time Listener to the beginning of the listeners. PrependOnce(e Event, lis Listener) error // Emit synchronously calls each of the listeners registered for the specified Event, // in the order they were registered. Emit(e Event) error // AsyncEmit asynchronously calls each of the listeners registered for the specified Event. AsyncEmit(e Event) <-chan error // Off removes the specified Listener from the listeners. Off(e Event, lis Listener) error // OffAll removes all listeners for the specified Event. OffAll(e Event) error // Close bus gracefully. Close(ctx context.Context) error }
type ErrListener ¶
func (ErrListener) Error ¶
func (e ErrListener) Error() string
type Event ¶
type Event interface { // When return the time of the event. When() time.Time // ID return the id of the event. ID() any // Body return the body of the event. Body() any // Type return the body's reflect.Type of the event. Type() reflect.Type // WithContext returns a shallow copy of e with its context changed to ctx. // The provided ctx must be non-nil. WithContext(ctx context.Context) Event // Context returns the context of the event. To change the context, use WithContext. Context() context.Context }
Event is an interface with a specific type that is associated to a specific Listener.
Click to show internal directories.
Click to hide internal directories.