javascript - Backbone/Backbone-Relational with Custom Sync -


i working on backbone.js app. using 3rd party api access data in app. 3rd party api not provide standard rest interface backbone expects.

i have heard can extend or overload backbone.sync function make backbone work 3rd party api, have not been able find examples determine how might done.

does know of examples or tutorials available this? can provide example?

also, discovered backbone-relational, may come in handy in application data relational. however, concerned using backbone-relational custom backbone.sync function may cause problems well. have experience this?

generally speaking, write custom functions perform basic crud operations using 3rd party api, overwrite backbone.sync switch on method use.

backbone.sync = function(method, model, options){   switch(method) {     case 'create':       console.log('creating: ', model);       break;     case 'read':       console.log('reading: ', model);       break;     case 'update':       console.log('updating: ', model);       break;     case 'destroy':       console.log('destroying: ', model);       break; } 

for more depth , walkthrough, check out dailyjs's backbone+requirejs+googleapi's tutorial, part 2 , part 4.

for example, check out source code of backbone localstorage adapter, overwrites backbone.sync persist localstorage instead of across network.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -