eventbus

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

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 is a shortcut for NewAwaiter(bus).Once(ctx, names...). See Awaiter.Once for documentation.

func New

func New() event.Bus

New returns a thread-safe in-memory event bus.

Types

type Awaiter

type Awaiter[D any] struct {
	// contains filtered or unexported fields
}

Awaiter can be used to await events in more complex scenarios.

func NewAwaiter

func NewAwaiter[D any](bus event.Bus) Awaiter[D]

NewAwaiter returns an Awaiter for the given Bus.

func (Awaiter[D]) Once

func (a Awaiter[D]) Once(ctx context.Context, names ...string) (<-chan event.Of[D], <-chan error, error)

Once subscribes to the given events. After the first received event, the subscription is canceled, so that the returned event and error channels will never receive more than one event or one error, respectively.

If len(names) == 0, Once returns nil channels.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL