Created
February 7, 2014 04:15
-
-
Save dbouwman/8857308 to your computer and use it in GitHub Desktop.
Snipped of a model where we add timing code around an xhr
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
... | |
fetch: function(){ | |
var url = this.get('url'); | |
var self = this; | |
//start the timer | |
App.startTimer('dataset-fetch', 'ajax', 'Dataset: ' + this.get('id')); | |
//closure for the callback | |
var doneCB= function(data){ | |
self.loadFromJson(data); | |
//stop the timer | |
App.stopTimer('dataset-fetch'); | |
}; | |
//make the call (via App) tack on the callback | |
var jqXhr = App.getJSON(url).done(doneCB); | |
//return the promise | |
return jqXhr; | |
}, | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment