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 faulty loop management when unsubscribing listeners #90

Closed
wants to merge 2 commits into from

Conversation

kytart
Copy link
Contributor

@kytart kytart commented Jan 23, 2016

There's a bug in the nested foreach loop.

It iterates over all listeners for the given event, searching for the index of the subscriber, that should be unsubscribed for this event. When the subscriber in the current iteration isn't the one we're looking for, it should continue to the next one. However there's continue(2) instead, which causes all other subscribers to be skipped and the loop continues with next event.

The result is that, if the subscriber is first in the array of subscribers for a given event, it's successfully unsubscribed as expected. If it's not the first, then it won't be unsubscribed because the whole array will be skipped.

This commit fixes the bug, changing continue(2) to continue to properly continue to another subscriber in the array.

@enumag
Copy link
Member

enumag commented Jan 23, 2016

Can you add a test?

@kytart
Copy link
Contributor Author

kytart commented Jan 23, 2016

Ok, I will later

@fprochazka
Copy link
Member

It would be great if you could add a test case, so nobody will break it again.

@fprochazka
Copy link
Member

I've written the test-case myself, so I could merge this. Thank you for reporting the issue and providing a fix!

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