noveogroup / backbone.iobind

Bind socket.io events to backbone models & collections. Also includes a drop-in replacement for Backbone.sync using socket.io.
https://noveogroup.github.io/backbone.iobind/
582 stars 65 forks source link

Update version compatibility. #17

Closed logicalparadox closed 9 years ago

dhruv-bhatia commented 12 years ago

Hi logicalparadox,

Is there an ETA on when one can expect this? It seems backbone.iobind doesn't work with Backbone v0.9.2 & Socket.IO v0.9.6. :(

Thanks!

logicalparadox commented 12 years ago

Looks like a lot has changed on those projects since the last release of ioBind. I will see what I can do over the next few days. Are you getting errors? If so, can you include them here so I can narrow it down?

logicalparadox commented 12 years ago

Also, see #12, as it might be relegated to some of your issues.

dhruv-bhatia commented 12 years ago

Thanks!

I'm using Brunch.IO to build my project and this uses Require.js, so it looks like #12 is the issue. Basically I can include Socket.IO and create a WS connection, but whenever I include the backbone.iobind.js and backbone.iosync.js files I get the following errors re: Handlebars/Underscore:


Error: Cannot find module 'underscore'
[Break On This Error]   

throw new Error("Cannot find module '" + name + "'");

vendor.js (line 59)
TypeError: Handlebars is undefined
[Break On This Error]   

...le.exports = Handlebars.template(function (Handlebars,depth0,helpers,partials,da...

app.js (line 520)

Thanks for pointing me towards Issue #12, I'll try saifbechan's workaround.

saifbechan commented 12 years ago

I just updated to the latest version of Socket.IO [0.9.6], and I can confirm that everything works just fine. I am also using the latest version of all other depending packages.

The workaround I described is only necessary when you are using require.js, which, if I understand correctly, you are. I think the big problem arose when Backbone.js and Underscore.js stopped supporting AMD out of the box. So when you have scripts that are loaded via require.js, and depend on Underscore.js or Backbone.js you have a problem.

There are a lot of solutions to this. My solution was a small fix called use.js which adds AMD support to files that do not support it out of the box. When set up correctly only thing that changes is the following:

require('underscore')

becomes

require('use!underscore')

And everything will play nice again. Note that this has to be changed in all the files where this is used.

dombesz commented 12 years ago

Due to backbone compatibility reasons (see here: https://github.com/documentcloud/backbone/issues/1424) the namespaces in urls for models and collections are getting mixed up. If you check your todo example app, after you update backbone the delete namespace becomes todo/[id]:delete instead of todos/[id]:delete