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

"notify" drops previous listeners when a new one connects #1

Closed
paullessing opened this issue Jan 11, 2016 · 1 comment
Closed

"notify" drops previous listeners when a new one connects #1

paullessing opened this issue Jan 11, 2016 · 1 comment

Comments

@paullessing
Copy link

The way the Observables are set up in Dispatcher#18-20 and HeroesStore#17-19 only ever allows a single listener on the observables. Since on every new subscriber connection the notify object is overwritten, only the latest connected subscriber will get updates.

In this example this is not a problem since there is only ever one subscriber per observable, but when more than one subscriber is listening to e.g. the Dispatcher, or the Store, this pattern does not work. The notify method has to be replaced with either a list of listeners, or the observable should be replaced with a Subject on which we can call .next() and which automatically handles connections and notification.

I'm mentioning this because I spent an hour yesterday trying to debug why my listeners weren't being called when I used this pattern, and want to avoid others having the same problem...

@paullessing paullessing changed the title _notify drops previous listeners when a new one connects notify drops previous listeners when a new one connects Jan 11, 2016
@paullessing paullessing changed the title notify drops previous listeners when a new one connects "notify" drops previous listeners when a new one connects Jan 11, 2016
@edconolly
Copy link
Owner

Have tested and can replicate. I've got a fix using Subjects instead, just need to update the docs + blog.

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

2 participants