tcorral / Hydra.js

Create a scalable, maintainable and module oriented system using Hydra.js
http://tcorral.github.com/Hydra.js
MIT License
102 stars 12 forks source link

Event unsubscribing bug #13

Closed Ramonacus closed 11 years ago

Ramonacus commented 11 years ago

There is a bug in the unsusbcribeFrom method: when iterating over the array we eventually remove an element but without updating the index or length variables. This causes an element in the array to be skipped and creates a call over an undefined array index.

I would suggest iterating in reverse order.

Ramonacus commented 11 years ago

Related to it, there is also an issue in the publish method. If in the callback of any notification we are removing a subscription, the publish method will fail in a similar fashion as stated above.

I would suggest either iterating in reverse order or storing the callbacks in another array to launch the first array has been completely iterated over.

tcorral commented 11 years ago

Thanks Ramonacus this issue has been fixed in version 3.1.3

Ramonacus commented 11 years ago

:)