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

fixed unsubscribe bug for issue #938 #939

Merged
merged 3 commits into from
Oct 23, 2015
Merged

Conversation

jzlxiaohei
Copy link
Contributor

No description provided.

@@ -62,6 +62,7 @@ export default function createStore(reducer, initialState) {

return function unsubscribe() {
var index = listeners.indexOf(listener);
if (index === -1)return;
Copy link
Contributor

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);
}

Copy link
Contributor

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!

Copy link
Contributor

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.

@gaearon
Copy link
Contributor

gaearon commented Oct 23, 2015

Thank you for the PR! I left a nit, will be happy to merge after it's fixed.

gaearon added a commit that referenced this pull request Oct 23, 2015
fixed unsubscribe bug for issue #938
@gaearon gaearon merged commit cb7f4fd into reduxjs:master Oct 23, 2015
@gaearon
Copy link
Contributor

gaearon commented Oct 23, 2015

I changed your fix to cover one more edge case: b7031ce

@jzlxiaohei
Copy link
Contributor Author

nice 🤘

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

Successfully merging this pull request may close these issues.

None yet

3 participants