Skip to content

Add plugin for Backbone.js. #220

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

Merged
merged 1 commit into from
Jun 25, 2014
Merged

Conversation

DouweM
Copy link
Contributor

@DouweM DouweM commented Jun 25, 2014

No description provided.

@mattrobenolt
Copy link
Contributor

I will trust that this works. :)

Does it just need to be included on the page and it'll automatically patch things? Or does it need to be explicitly injected somehow? Angular plugin, for example, needs to be registered into the application before it can be used.

mattrobenolt added a commit that referenced this pull request Jun 25, 2014
@mattrobenolt mattrobenolt merged commit be55b61 into getsentry:master Jun 25, 2014
@DouweM
Copy link
Contributor Author

DouweM commented Jun 25, 2014

Just include this in the page this after Raven and Backbone and you should be fine.

I've tested it with our fairly large Backbone app and it seems to work great. It's possible I've forgotten to cover some edge cases, but it definitely shouldn't break anything.

@mattrobenolt
Copy link
Contributor

Can you confirm that I didn't break it with bdda4e9 ?

@DouweM
Copy link
Contributor Author

DouweM commented Jun 25, 2014

The function builder looks nicer, but you broke it! Watch closely what happens with callback, _callback and callback._callback. Raven.wrap() should still wrap callback and oldOn should be called with the new wrapped callback.

@DouweM
Copy link
Contributor Author

DouweM commented Jun 25, 2014

Fixed version:

function makeBackboneEventsOn(oldOn) {
  return function BackboneEventsOn(name, callback, context) {
    var _callback = callback._callback || callback;
    callback = Raven.wrap(callback);
    callback._callback = _callback;

    return oldOn.call(this, name, callback, context);
  };
}

I went the verbose if/else way because of the jquery plugin btw, not because I preferred it, but this case is somewhat more straight forward than the one in the jquery plugin.

@mattrobenolt
Copy link
Contributor

Ohh, haha, I see what I did. One sec.

@mattrobenolt
Copy link
Contributor

See: 7aec844

Sorry, I was cleaning it up because jshint was complaining.

@DouweM
Copy link
Contributor Author

DouweM commented Jun 25, 2014

Looks good to me!

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