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

simpler 'unbind' with scope (string) instead of function #3

Open
gr2m opened this issue Nov 14, 2011 · 0 comments
Open

simpler 'unbind' with scope (string) instead of function #3

gr2m opened this issue Nov 14, 2011 · 0 comments

Comments

@gr2m
Copy link

gr2m commented Nov 14, 2011

Hey Dimitry,

I do highly respect your JavaScripts and maybe my suggestion is nonsense, I'd be happy for a hint what you would do.

Here's my scenario:

I have several models that subscribe to events from a socket. With eve, the binding would look like:

eve.on('change/Model_xyz', function() { ... })

There are tons of bindings all around the place. My understanding is that I could not simply unbind the particular event above, I'd need to wrap the anonymous function into some method (e.g. Model.make_stuff) and then pass this method when I do an unbind, correct?

eve.unbind('change/Model_xyz', Model.make_stuff)

I wonder if it would make sense to extend the implementation of eve, so that I could use a simple string to scope a bind/unbind. It my example, it would look like:

eve.on('change/Model_xyz', function() { ... }, 'unique_id_here')
eve.unbind('change/Model_xyz', 'unique_id_here')

What do you think? Does that make any sense to you?

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

1 participant