You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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...
The text was updated successfully, but these errors were encountered:
paullessing
changed the title
_notify drops previous listeners when a new one connectsnotify drops previous listeners when a new one connects
Jan 11, 2016
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
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 aSubject
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...
The text was updated successfully, but these errors were encountered: