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.
syncdetermines 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
Tthat returns a result of typeR. 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. IforElseis provided, it will be called if no handler is registered immediately (non-blocking). IforElseis 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