Skip to content

Instantly share code, notes, and snippets.

@dbouwman
Created February 7, 2014 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbouwman/8857308 to your computer and use it in GitHub Desktop.
Save dbouwman/8857308 to your computer and use it in GitHub Desktop.
Snipped of a model where we add timing code around an xhr
...
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