-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Prevent invalidating subscription iterator #1438
Changes from all commits
c99619d
e404657
9d040ab
d2c310d
9cddc8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,7 +101,10 @@ export class Store { | |
handler(payload) | ||
}) | ||
}) | ||
this._subscribers.forEach(sub => sub(mutation, this.state)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we also need to do the same thing for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, I've shared it through a new |
||
|
||
this._subscribers | ||
.slice() // shallow copy to prevent iterator invalidation if subscriber synchronously calls unsubscribe | ||
.forEach(sub => sub(mutation, this.state)) | ||
|
||
if ( | ||
process.env.NODE_ENV !== 'production' && | ||
|
@@ -132,6 +135,7 @@ export class Store { | |
|
||
try { | ||
this._actionSubscribers | ||
.slice() // shallow copy to prevent iterator invalidation if subscriber synchronously calls unsubscribe | ||
.filter(sub => sub.before) | ||
.forEach(sub => sub.before(action, this.state)) | ||
} catch (e) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you write some comment to share the context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!