noveogroup / backbone.iobind

Bind socket.io events to backbone models & collections. Also includes a drop-in replacement for Backbone.sync using socket.io.

Home Page:https://noveogroup.github.io/backbone.iobind/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle both normal Backbone.sync and socket.io sync

opened this issue · comments

I only have part of my api that is using socket.io. The other part is a pure reset AJAX model. How can I support a normal Backbone fetch but also utilize backbone.iobind for socket.io calls. Since backbone.iobind is overwriting Backbone.sync, it looks to be not possible. Any suggestions?

I've made a fix by returning the original sync if no socket is passed in

https://github.com/blairvanderhoof/backbone.iobind/commit/02e6f5dbb933351d5d8b44804b73f39a125fe10e#dist/backbone.iosync.js

(Based off mauron85/backbone.iobind since i also need the requirejs support)

@blairvanderhoof this seems to only work on initial load, subsequent fetches on a normal Backbone.sync collections fail. I added this to my backbone.iosync.js, and it is working for me,

        if (false === model.socket) {
            return origSync(method, model, options);
        }

However, I still have to add a socket: false property to my regular backbone model.

@corpulent @blairvanderhoof implemented in verison 0.4.8