开发者

rewrite backbone.sync

开发者 https://www.devze.com 2023-04-05 19:56 出处:网络
I\'m using backbone.js with websockets and sending data to the server based on events. Is it possible to design/rewrite Backbone.sync to transport model changes to the server in a normalized way?

I'm using backbone.js with websockets and sending data to the server based on events.

Is it possible to design/rewrite Backbone.sync to transport model changes to the server in a normalized way?

Any general examples of this would be great, t开发者_如何转开发hen I can figure out how to integrate it with my server-side methods.

Thanks!


I would start with the documentation and the annotated source for the Backbone.Sync function.

Then, see how the "local storage" module modifies Backbone.Sync to store locally instead of to the server as an example of overriding behavior.

Perhaps, this Stack Overflow Question will also help.


Backbone.Sync has very little code, and it's common to re-write it to work the way you need. I would start by reading the annotated code, and then there are several plugins that you can look at for examples of how to rewrite it yourself.


There is module called backbone.io, try npm install backbone.io

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号