1.1.0 • Published 9 years ago

backbone.conduit v1.1.0

Weekly downloads
11
License
MIT
Repository
github
Last release
9 years ago

Backbone.Conduit

Moving Data Through Backbone

Conduit is a Backbone plugin that improves the ability of Backbone to handle large scale data sets.

Build Status Join the chat at https://gitter.im/pwagener/backbone.conduit

Install it with npm or bower:

$ bower install backbone.conduit
... or ...
$ npm install backbone.conduit

Option #1: Faster Model Creation

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.

Option #2: Async Data Management + Deferred Model Creation

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.

Interesting. Can you tell me more?

Reading bores me. Can you show me instead?

I Think It's Broken.

I Have A Question

Great! Either ...

1.1.0

9 years ago

1.0.0

9 years ago

0.6.19

10 years ago

0.6.18

10 years ago

0.6.17

10 years ago

0.6.16

10 years ago

0.6.15

10 years ago

0.6.14

10 years ago

0.6.13

10 years ago

0.6.12

10 years ago

0.6.11

10 years ago

0.6.10

10 years ago

0.6.9

10 years ago

0.6.8

10 years ago

0.6.7

10 years ago

0.6.6

10 years ago

0.6.5

10 years ago

0.6.4

10 years ago

0.6.3

10 years ago

0.6.2

10 years ago

0.6.1

10 years ago

0.6.0

10 years ago

0.4.4

10 years ago

0.4.3

10 years ago

0.4.2

10 years ago

0.4.1

10 years ago

0.4.0

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago