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 subscriptions are snapshotted just before every dispatch() call. If you subscribe or unsubscribe while the listeners are being invoked, this will not have any effect on the dispatch() that is currently in progress. However, the next dispatch() call, whether nested or not, will use a more recent snapshot of the subscription list.
If so: how does Redux handle this issue? Or is it something that the users must just be aware of?
onStateChanged
method from aStateChangeListener
can be called after it hasunsubscribe
d.Steps:
Thread 1
, S starts notifying listeners usingNotifySubscribersMiddleware
.CopyOnWriteArrayList
is used to keep the listeners. Therefore, we iterate using a copy of the list that won't be changed during the iterator loop.Thread 2
, L callsunsubscribe
to unsubscribe from the Store S. This happens before step 3 is over and L is notified.onStateChanged
, even thought it is already unsubscribed.The scenario looks difficult to reproduce, however the consequences can be fatal.
The text was updated successfully, but these errors were encountered: