Skip to content

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

@gr2m

Description

@gr2m

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions