This repository is now archived, and the NPM package is deprecated.
Conduit is a Backbone plugin that improves the ability of Backbone to handle large scale data sets.
Install it with npm
or bower
:
$ bower install backbone.conduit
... or ...
$ npm install backbone.conduit
Conduit.QuickCollection
is optimized to create Backbone.Model instances faster:
var collection = new Backbone.Conduit.QuickCollection();
// If you have a large amount of data injected onto the page, instead of 'reset(...)' do ...
var aBigArray = [ {}, {}, {} ]; // let's assume this was 100K objects
collection.refill(aBigArray);
// Or, if you need to get it asynchronously, instead of 'fetch()' do ...
collection.haul();
Performance varies, but typically loading data into a Conduit.QuickCollection
is ~ 40% faster than a Backbone.Collection
.
Conduit.SparseCollection
drastically changes how data is managed in a Collection. Raw data is managed in a web worker,
and model creation only happens when data is prepared for use in a View. Sort, Filter, Map and Reduce, and other
methods are asynchronous, using Promises to manage the flow:
var MyCollection = Backbone.Conduit.SparseCollection.extend({
// Assume this endpoint returns 100K items:
url: '/some/enormous/data',
// ...
});
Backbone.Conduit.enableWorker({
paths: '/your/path/to/backbone.conduit'
}).then(function() {
var collection = new MyCollection();
return collection.haul();
}).then(function() {
console.log('Length: ' + collection.length); // <== "Length: 100000"
// Prepare the first 10 models for use
return collection.prepare({
indexes: { min: 0, max: 9}
});
}).then(function(models) {
console.log('Prepared: ' + models.length); // <== "Prepared: 10"
// Note the prepared models are also available via
// 'collection.get(...)' or 'collection.at(...)';
});
Since model creation happens at the last possible moment, and the worker thread handles the data management,
a SparseCollection
can handle hundreds of thousands of items easily.
- Sure! Here's The Documentation.
- Yes! Check out the Demo.
- Oh No! Please File An Issue.
Great! Either ...
- Send a note via Gitter
- Send a note via Twitter