/backbone-sync-deferred

Ultra lightweight & seamless Backbone.sync override to work with promises.

Primary LanguageJavaScript

Backbone-sync-deferred

Build Status (tests are really messy right now)

Ultra lightweight & seamless Backbone.sync override to work with promises.

Just include the script after backbone. And you'll be able to do :

var myModel = new Backbone.Model();
myModel.url = "https://my.balling-api.com/whatever";

myModel.fetch().then(function(data){
  console.log(data);
  // data is RAW json
  // however, classic "callback" is still called seamlessly so:
  // data.attribute == myModel.get('attribute')
},
function(response){
  console.log(response.statusText);
});

And basically use them on every methods that is using Backbone.sync (collection fetch, model save, etc....)