-
-
Save JonMidhir/adee34b35acf87bae443 to your computer and use it in GitHub Desktop.
Tracking Backbone errors with track:js, ported to CoffeeScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# OPTION 1: | |
# Automatically wrap everything | |
do -> | |
'use strict' | |
return unless window.trackJs? | |
for klass in ['View', 'Model', 'Collection', 'Router'] | |
old = Backbone[klass] | |
class Backbone[klass] extends old | |
constructor: -> | |
@_trackJs = true unless @_trackJs? | |
trackJs.watchAll(this, 'model', 'constructor') if @_trackJs # additional parameters are excludes. Collection.model does not support watching. | |
super | |
# OPTION 2: | |
# Selectively wrap objects on instantiation. | |
class MyView extends Backbone.View | |
initialize: -> | |
window.trackJs?.watchAll(this, 'excludedFunction') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment