Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Holding events #46

Closed
jrojas25 opened this issue Dec 2, 2021 · 3 comments
Closed

Holding events #46

jrojas25 opened this issue Dec 2, 2021 · 3 comments

Comments

@jrojas25
Copy link

jrojas25 commented Dec 2, 2021

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?

@visign3d
Copy link

maybe try the synchronous event bus
EventBus eventBus = EventBus(sync: true);

@sunnykinger
Copy link

maybe try the synchronous event bus EventBus eventBus = EventBus(sync: true);

doesn't work

@marcojakob
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants