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

on is a noop if no callback is provided #1008

Merged
merged 1 commit into from
Feb 14, 2012
Merged

on is a noop if no callback is provided #1008

merged 1 commit into from
Feb 14, 2012

Conversation

braddunbar
Copy link
Collaborator

No description provided.

@jashkenas
Copy link
Owner

Eh? Why would you possibly want to "bind" without passing a callback? Isn't that an error by definition?

@braddunbar
Copy link
Collaborator Author

Agreed. However, the current implementation waits until trigger to raise an error (due to a null callback). We could check for it there but it seems silly to add empty callbacks to the list. If it's an error condition then perhaps we should raise an error, but doing nothing seems wrong.

@jashkenas
Copy link
Owner

Ah, gotcha.

jashkenas added a commit that referenced this pull request Feb 14, 2012
`on` is a noop if no callback is provided
@jashkenas jashkenas merged commit 04e2e20 into jashkenas:master Feb 14, 2012
byroot added a commit to byroot/backbone that referenced this pull request Jan 23, 2013
…pe.on and Events.prototype.once

Rationale:

  - As stated by @jashkenas in jashkenas#1008 binding a event without passing a callback is "an error by definition".

  - "Errors should never pass silently".

  - If I reference a method that do not exists in a view `events` hash,
    it will throw and error when I instanciate the view, and I'll fix that issue in a minute.

  - Before jashkenas#1008 a typo like `.on('change', this.rander, this)` would have thrown an error quickly.
    Now since 0.9.9 these typos became a noop, so the only way to spot this kind of issues is to wonder
    why your callback is never called.

I know this is a backward incompatible change, but it will only break dead code writen for 0.9.9 or 0.9.10.
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

Successfully merging this pull request may close these issues.

2 participants