0.1.1 • Published 9 years ago

minimal-flux-stores v0.1.1

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

minimal-flux-stores

Immutable stores for minimal-flux. Work in progess!

Travis David NPM

Install

npm install minimal-flux-stores --save

Stores

  • ImmutableStore extends minimal-flux.Store
    • Stores immutable data
  • CollectionStore extends ImmutableStore
    • Stores and indexes a collection of items
  • ResourceStore extends CollectionStore
    • Manages a remote collection, for example via REST
    • Similar to Backbone.Collection

Actions

  • CollectionActions extends minimal-flux.Actions
    • Provides predefined actions for CollectionStore
    • Actions: add, change, remove
  • ResourceActions extends CollectionActions
    • Provides predefined actions for ResourceStore
    • Actions: fetch, fetchSuccess, fetchError, create, createSuccess, createError, createValidationError, update, updateSuccess, updateError, delete, deleteSuccess, deleteError
    • Needs an adapter to communicate with a server, e.g. RestAdapter

Adapters

  • Adapter
    • Abstract adapter for ResourceActions
  • RestAdapter extends Adapter
    • Implements read, create, update, delete for use with a REST-API

Performance

minimal-flux-stores is developed with performance in mind. The stores are benchmarked against the well performing Backbone.Collection. See the results:

targetops/secvarianceruns
ResourceStore#add 125,231±3.00%62
ResourceStore#add 210,506±4.14%58
ResourceStore#add 32678±3.79%72
ResourceStore#add 102419.03±4.55%36
ResourceStore#add 2 batch11,932±3.88%54
ResourceStore#add 32 batch1,061±2.52%70
ResourceStore#add 1024 batch31.86±2.66%43
CollectionStore#add 145,753±4.68%54
CollectionStore#add 223,905±3.97%65
CollectionStore#add 321,548±3.20%76
CollectionStore#add 102447.64±2.08%54
CollectionStore#add 2 batch33,084±2.98%63
CollectionStore#add 32 batch3,556±3.08%74
CollectionStore#add 1024 batch132±2.89%71
Backbone.Collection#add 154,153±1.96%84
Backbone.Collection#add 228,445±2.42%79
Backbone.Collection#add 321,741±1.89%82
Backbone.Collection#add 102450.19±2.78%55
Backbone.Collection#add 2 batch35,869±1.82%89
Backbone.Collection#add 32 batch2,605±1.93%82
Backbone.Collection#add 1024 batch86.83±3.34%67

To run the benchmarks, make sure you have installed all dependencies. Then run npm run perf in the root directory

Examples

You can find more examples in examples/. Run the following commands to make the examples work:

# Run install for minimal-flux-stores in the root directory
npm install
# Change to one of the examples
cd examples/<example>
# Install example dependencies
npm install
# Start the server
npm start

Then open the http://localhost:3000 in your browser.