spoike/refluxjs — pull request #95 by krawaller (2014-10-03 07:50:26+00:00)
Title: fix listen cancellation bug

This is a bad one; I made a(nother) serious error in the big refactor! Potentially, when cancelling a subscription, the wrong object will be removed from the subscriptions list! The previous tests unfortunately missed this by pure bad luck, as it had the listener to be removed in the last position, and that's what always will be removed (since splice is given the index -1).

I've fixed the bug, added more cancellation tests, and also thrown out the flag to allow stopping a subscription without clearing it from the subscriptions list. The only reason for having it was to safely be able to iterate over the array when we want to `stopListeningToAll`. I changed that now to use a while loop which throws an error if a removal fails. We also throw an error for a single cancellation if the removal fails.

All in all this should mean a pretty robust cancellation solution.