0.1.0 • Published 10 years ago
backbone.aio v0.1.0
Backbone.aio
A super-simple plugin which replaces Backbone's default AJAX transport with Socket.io.
It hooks into Backbone.ajax
- not Backbone.sync
- leaving the sync layer untouched for easier integration with other libraries.
Features
- Drop-in replacement which doesn't necessitate any changes to your front-end code.
- Simple, explicit push and pull behaviour.
- ~2kb minified, even without compression.
Usage
Usable in both an AMD and non-AMD context. Once loaded into your runtime, you must first provide your socket.io socket instance:
var socket = io(window.location.origin);
Backbone.Aio.setSocket(socket);
Please see the code in /docs
for an example of usage, including additional features suchs as .link()
.
What it does
- Transforms all Backbone AJAX requests into socket.io events and emits them from the client.
- Channels server responses to client-side events through Backbone's event mechanisms.
- Lets you invoke client-side methods by emitting server-side events using the
link
method. - Assumes that all Backbone model IDs are numerical (a caveat of only having the AJAX request URL to work with).
What it doesn't do
- Provide any automatic synchronisation between server and client instances of Backbone models and collections. There is no requirement to use Backbone server-side.
0.1.0
10 years ago