spacenick / backbone-sync-deferred

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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....)

About

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


Languages

Language:JavaScript 100.0%