EventBus class Null safety

EventBus is a stream based solution to remove dependencies between elements.

Usage:

final bus = EventBus([
  EventTransformer(HeightProvidedEvent, (event, eventBus) => BmiCalculatedEvent()),
  EventTransformer(WeightProvidedEvent, (event, eventBus) => BmiCalculatedEvent()),
]);
bus.publish(WeightProvidedEvent());
final outputStream = bus.select<BmiCalculatedEvent>();

You can now listen to the outputStream

TODO: Find a way to check circular transformations and remove them.

Implemented types
Annotations

Constructors

EventBus([List<EventTransformer<Object, Object>>? transformers])
EventBus will start listening to events when constructed. [...]
EventBus.from(EventBus other)
Creates a copy from another bus.
EventBus.withLogger([List<EventTransformer<Object, Object>>? transformers])
Creates an EventBus with logging ability.
factory

Properties

hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
store Store
Events are stored here.
final
stream Stream<Object>
The internal stream is exposed for customized listening. [...]
read-only
transformers Iterable<EventTransformer<Object, Object>>
A list of transformers extracted from transformerMap.
read-only

Methods

cancelFromStream(String id) EventBus
dispose() Future<void>
Disposes the SubscriptionManager. Closes the StreamController. Unregisters all the Transformers.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
publish(Object message) EventBus
Publishes a single message.
publishAndSave(Object message) EventBus
Publishes and saves messages to store.
publishAndSaveFromFuture(Future<Object> future) EventBus
Publishes and saves the message after resolving a future.
publishAndSaveFromStream(Stream<Object> stream, String id) EventBus
Publishes and saves messages as the stream emits.
publishAndSaveMany(Iterable<Object> messageList) EventBus
Publishes and saves multiple messages.
publishFromFuture(Future<Object> future) EventBus
Publishes the message after resolving a future.
publishFromStore<T extends Object>() EventBus
Publishes a message from store.
publishFromStream(Stream<Object> stream, String id) EventBus
Publishes messages as the stream emits.
publishMany(Iterable<Object> messageList) EventBus
Publishes multiple messages.
registerTransformers(List<EventTransformer<Object, Object>> transformers) EventBus
Registered transformers will run when a source event is hit.
save(Object message) EventBus
Saves message to store.
select<T extends Object>() Stream<T>
Selects a message of type T.
selectFromStore<T extends Object>() → T
Selects a message of type T from store.
toString() String
A string representation of this object. [...]
inherited

Operators

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