Skip to content

Allow sending events in a StreamController's onListen callback. #30532

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

Open
lrhn opened this issue Aug 24, 2017 · 1 comment
Open

Allow sending events in a StreamController's onListen callback. #30532

lrhn opened this issue Aug 24, 2017 · 1 comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. core-2 library-async type-enhancement A request for a change that isn't a bug

Comments

@lrhn
Copy link
Member

lrhn commented Aug 24, 2017

The current contract for using synchronous stream controllers say that you must not send events immediately in the onListen callback.

Allowing this would make it easier to implement a Replay functionality by sending all events immediately, and then just staying up-to-speed with future events.

There is no problem doing this with an asynchronous completer because it won't send the event immediately, but a synchronous completer will send the event at a time where the listener might not have set up their callbacks yet (listener callbacks can be set on the subscription object instead of being passed in the listen call). In general, events occurring immediately when you call listen, before the subscription has been returned, has been found to be error-prone with the current API.

There is no combined sync/async controller that can send the first events asynchronously and later events synchronously, which might also handle the same issue.

@lrhn lrhn added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. core-m library-async type-enhancement A request for a change that isn't a bug labels Aug 24, 2017
@floitschG floitschG added core-2 and removed core-m labels Sep 7, 2017
@rrousselGit
Copy link

rrousselGit commented Oct 12, 2018

This has recently been the topic of discussions with Brian Egan for Behavior/ReplaySubject in rxdart.

It seems that to have a "true" Behavior/ReplaySubject, rxdart would have to entirely rewrite StreamController.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. core-2 library-async type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants