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

Cannot one() recursively #121

Open
fabiosantoscode opened this issue Mar 11, 2015 · 1 comment
Open

Cannot one() recursively #121

fabiosantoscode opened this issue Mar 11, 2015 · 1 comment

Comments

@fabiosantoscode
Copy link
Contributor

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.

http://jsbin.com/fepada/1/edit?html,js,output

@rvagg
Copy link
Collaborator

rvagg commented Mar 11, 2015

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.

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

No branches or pull requests

2 participants