EventBus class
Basic Event bus implementation
You can send events and streamOf to stream of event callbacks or collection of events callbacks with streamOfCollection
void example() {
final subscription = EventBus.instance.listenToCollection(['initialized', 'disposed']).listen((event) {
// do something with events
});
EventBus.instance.send(BusEventData('initialized', {
'currentTime': DateTime.now()
}));
subscription.cancel();
}
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDisposed → bool
-
Flag indicating that this event bus is disposed
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
checkEventWasSent(
Type event) → bool - Returns true if underlying events list contains given event name
-
dispose(
) → void - Closes underlying stream controller
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
send(
dynamic event) → void - Sends event to stream controller
-
streamOf<
T> () → Stream< T> - Return dart stream of events with particular name
-
streamOfCollection(
List< Type> events) → Stream - Return dart stream of events with particular names
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
newSeparateInstance(
) → EventBus - Creates separate instance of event bus