EventBus class

A simple EventBus that supports both Publish/Subscribe and Request/Response patterns.

Constructors

EventBus()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

close() → void
Closes the event bus.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
on<T extends Event>() Stream<T>
Listens for events of type T.
publish(Event event, {bool sync = false}) → void
Publishes an event to all subscribers. sync determines whether the event is fired synchronously or asynchronously.
registerRequestHandler<T extends Event, R>(Future<R> handler(T)) → void
Registers a handler for a specific event type T that returns a result of type R. Only one handler can be registered per event type.
request<R>(Event event, {R orElse()?}) Future<R>
Sends a request event of type Event and awaits a result of type R. The event type must have a registered handler. If orElse is provided, it will be called if no handler is registered immediately (non-blocking). If orElse is NOT provided and no handler is registered, it will throw an exception immediately.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited