Cannot `one()` recursively
fabiosantoscode opened this issue · comments
A bean.one(elm, type, handler)
handler cannot itself invoke bean.one
with the same element, type and function. Here's an example where I listen for one mousemove
event, and in the handler decide to listen for another mousemove
event, but the handler never comes along.
http://jsbin.com/hobaya/1/edit?html,js,output
Result: my handler is called only for the first mousemove event
Expected: my handler should be called every time there is a mousemove event, since I explicitly listened to it again.
I figured out a workaround, which is to listen to a copy of the function. That produces the same effect because the copy !==
the original function.
http://jsbin.com/fosuvi/1/edit?html,js,output
Alternatively, using setImmediate or setTimeout to move the one()
call outside the call stack that resulted in calling the handler also works.
soooo .. unfortunately I don't have a whole lot of time to address this myself and since this doesn't impact me it's difficult to prioritise it. I know this isn't what you want to hear but if you could have a go at trying a fix and submitting a pull request then that'd get you much further.