-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
fixed unsubscribe bug for issue #938 #939
Conversation
@@ -62,6 +62,7 @@ export default function createStore(reducer, initialState) { | |||
|
|||
return function unsubscribe() { | |||
var index = listeners.indexOf(listener); | |||
if (index === -1)return; |
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.
Please be consistent with the project style.
In this case I'd rather write it as
if (index !== -1) {
listeners.splice(index, 1);
}
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.
Nitpick: index > -1
- saved 2 chars!
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.
I don't mind either way. 😛
I was kind of a fan of > -1
for some time, but now I think !== -1
makes the intention clearer.
But whatever, I'm fine with either.
Thank you for the PR! I left a nit, will be happy to merge after it's fixed. |
fixed unsubscribe bug for issue #938
I changed your fix to cover one more edge case: b7031ce |
nice 🤘 |
No description provided.