EventBus class
A singleton EventBus
EventBus's Event are subscribed by EventRule subscribe to call corresponding EventListener's callbacks.
Example
final event1 = Event<int>("int");
EventRule<int>(event1, targets: [
// On Receiving `event1` call `onEvent`
// with `payload` of type [int]
EventListener(
(payload) {
print("integer event: $payload");
},
),
]);
....
// Release Event
EventBus.emit(event1.createPayload(100))
// prints "integer event: 100"
See Also:
- EventListener : An EventListener which calls its onEvent.
- OneOffEventListener : An EventListener which only calls its onEvent one time.
- DebouncedEventListener : An EventListenr which delays its calls to prevent frequent calls.
- EventRule : An EventLoop Subscriber
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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
emit<
T> (_EventPayload< T> event) → void - To emit an event