derbyjs / racer

Realtime model synchronization engine for Node.js
1.19k stars 118 forks source link

Adding the same listener for multiple events breaks cleanup() #113

Closed SLaks closed 11 years ago

SLaks commented 11 years ago

model.on() returns the generated callback function (in case it generates a wrapper for paths), and adds a cleanup() method to it that removes the listener

However, if you add the same function as a handler for two different events, the cleanup() method will only ever remove the second event. (since both events will add the method to the same function instance)

For pathed listeners passed to on(), this is not a problem (since it generates a new wrapper every time)

SLaks commented 11 years ago

This problem is particularly bad for my onPath() method (not pull-requested), since it always returns the original function.

It broke event cleanup for queries with dependencies.

nateps commented 11 years ago

No longer relevant in 0.5