
Security News
VulnCon 2025: NVD Scraps Industry Consortium Plan, Raising Questions About Reform
At VulnCon 2025, NIST scrapped its NVD consortium plans, admitted it can't keep up with CVEs, and outlined automation efforts amid a mounting backlog.
backbone-socketio
Advanced tools
Realtime two-way data-binding of Backbone model and collection data to a webserver via Socket.io.
Realtime two-way data-binding of Backbone model and collection data to a webserver via Socket.io. Makes realtime, collaborative editing in Backbone applications (hopefully) much simpler.
Install the module: npm install backbone-socketio
.
Server-side event listeners are added by injecting the Socket.io module as a dependency:
var io = require('socket.io');
require('backbone-socketio').init(io);
// continue to do your normal socket.io stuff here
The only dependencies the client has are Underscore and Backbone.js. Using Cocktail to apply mixins to models or collections will make for a much nicer experience, but is not required.
Install the client-side code using Bower:
bower install backbone-socketio
or by downloading the minified file and hosting it on your server or CDN.
Include the file:
<script src="/bower_components/backbone-socketio/client/backbone-socketio.min.js"></script>
And mix the event listeners in using
Cocktail, or manually with extend
.
With Cocktail:
var socket = io.connect('http://localhost:3000'),
backboneMixins = new BackboneSocketio(socket),
MyModel, MyCollection;
MyModel = Backbone.Model.extend({ /* normal model init code here */ });
Cocktail.mixin(MyModel, backboneMixins.mixins.model);
MyCollection = Backbone.Collection.extend({ /* normal collection init code here */ });
Cocktail.mixin(MyCollection, backboneMixins.mixins.collection);
Without Cocktail:
var socket = io.connect('http://localhost:3000'),
backboneMixins = new BackboneSocketio(socket),
SocketModel = Backbone.Model.extend(backboneMixins.mixins.model),
SocketCollection = Backbone.Collection.extend(backboneMixins.mixins.collection),
MyModel, MyCollection;
MyModel = SocketModel.extend({
// normal model init code here
initialize: function () {
// if you need an initialize method make sure you call the parent's
// initialize function
MyModel.__super__.initialize.call(this);
}
});
MyCollection = SocketCollection.extend({
// normal collection init code here
initialize: function () {
// if you need an initialize method make sure you call the parent's
// initialize function
MyCollection.__super__.initialize.call(this);
}
});
This will set up listeners on all the necessary change events on models and collections then publish those changes down to the server. The server will then broadcast those changes back out to all other clients connected to the same socket and update the data in their corresponding models and collections.
Handling any DOM manipulation necessary to reflect changes in your views is up to you.
In lieu of a formal styleguide, take care to maintain the existing coding
style. Add unit tests for any new or changed functionality. Lint and test your
code using Grunt. grunt
will run unit tests and
JSHint.
sort
eventsBasic proof of concept. Full support for add and remove (collection) and change (model) events.
Copyright (c) 2013-2014 Josh Mock
Licensed under the MIT license.
FAQs
Realtime two-way data-binding of Backbone model and collection data to a webserver via Socket.io.
The npm package backbone-socketio receives a total of 0 weekly downloads. As such, backbone-socketio popularity was classified as not popular.
We found that backbone-socketio demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At VulnCon 2025, NIST scrapped its NVD consortium plans, admitted it can't keep up with CVEs, and outlined automation efforts amid a mounting backlog.
Product
We redesigned our GitHub PR comments to deliver clear, actionable security insights without adding noise to your workflow.
Product
Our redesigned Repositories page adds alert severity, filtering, and tabs for faster triage and clearer insights across all your projects.