Closed jrojas25 closed 2 years ago
maybe try the synchronous event bus
EventBus eventBus = EventBus(sync: true);
maybe try the synchronous event bus
EventBus eventBus = EventBus(sync: true);
doesn't work
The EventBus
uses Dart's Broadcast Streams. Broadcast streams do not cache events if nobody is listening:
Broadcast streams work the same as single subscription streams, but they can have multiple listeners, and if nobody’s listening when a piece of data is ready, that data is tossed out.
If you want to cache events it's probably best to create your own version of an event bus or have a look at something like StreamQueue.
BTW: Sync is not the same as caching the event:
/// If [sync] is true, events are passed directly to the stream's listeners
/// during a [fire] call. If false (the default), the event will be passed to
/// the listeners at a later time, after the code creating the event has
/// completed.
I'm having issues when firing an event before the listener is set, for this case the listener never gets the event. Are there any mechanism to hold the event until the listener is ready?