Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Await ¶
func Await[D any](ctx context.Context, bus event.Bus, names ...string) (<-chan event.Of[D], <-chan error, error)
Await returns a channel that receives the first occurrence of an event with one of the specified names from the provided event bus, along with a channel for errors and a possible error. The context is used to cancel the operation if needed. The returned channels should be read from to prevent goroutine leaks.
Types ¶
type Awaiter ¶
type Awaiter[D any] struct { // contains filtered or unexported fields }
Awaiter is a type that provides functionality to wait for specific events from an event.Bus, and then delivers them as typed events via channels. It supports cancellation through the provided context.Context.
func NewAwaiter ¶
NewAwaiter creates and returns a new Awaiter instance that uses the provided event.Bus to subscribe and wait for events.
func (Awaiter[D]) Once ¶
func (a Awaiter[D]) Once(ctx context.Context, names ...string) (<-chan event.Of[D], <-chan error, error)
Once listens for the first occurrence of the specified events in the context and returns a channel that emits the event, an error channel, and an error. If no event names are provided, it returns nil channels and no error. The context is used to cancel the operation if necessary.