0.1.1 • Published 10 years ago
minimal-flux-stores v0.1.1
minimal-flux-stores
Immutable stores for minimal-flux. Work in progess!
Install
npm install minimal-flux-stores --saveStores
- ImmutableStore
extendsminimal-flux.Store- Stores immutable data
- CollectionStore
extendsImmutableStore- Stores and indexes a collection of items
- ResourceStore
extendsCollectionStore- Manages a remote collection, for example via REST
- Similar to Backbone.Collection
Actions
- CollectionActions
extendsminimal-flux.Actions- Provides predefined actions for
CollectionStore - Actions:
add,change,remove
- Provides predefined actions for
- ResourceActions
extendsCollectionActions- 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
- Provides predefined actions for
Adapters
- Adapter
- Abstract adapter for
ResourceActions
- Abstract adapter for
- RestAdapter
extendsAdapter- 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:
| target | ops/sec | variance | runs |
|---|---|---|---|
| ResourceStore#add 1 | 25,231 | ±3.00% | 62 |
| ResourceStore#add 2 | 10,506 | ±4.14% | 58 |
| ResourceStore#add 32 | 678 | ±3.79% | 72 |
| ResourceStore#add 1024 | 19.03 | ±4.55% | 36 |
| ResourceStore#add 2 batch | 11,932 | ±3.88% | 54 |
| ResourceStore#add 32 batch | 1,061 | ±2.52% | 70 |
| ResourceStore#add 1024 batch | 31.86 | ±2.66% | 43 |
| CollectionStore#add 1 | 45,753 | ±4.68% | 54 |
| CollectionStore#add 2 | 23,905 | ±3.97% | 65 |
| CollectionStore#add 32 | 1,548 | ±3.20% | 76 |
| CollectionStore#add 1024 | 47.64 | ±2.08% | 54 |
| CollectionStore#add 2 batch | 33,084 | ±2.98% | 63 |
| CollectionStore#add 32 batch | 3,556 | ±3.08% | 74 |
| CollectionStore#add 1024 batch | 132 | ±2.89% | 71 |
| Backbone.Collection#add 1 | 54,153 | ±1.96% | 84 |
| Backbone.Collection#add 2 | 28,445 | ±2.42% | 79 |
| Backbone.Collection#add 32 | 1,741 | ±1.89% | 82 |
| Backbone.Collection#add 1024 | 50.19 | ±2.78% | 55 |
| Backbone.Collection#add 2 batch | 35,869 | ±1.82% | 89 |
| Backbone.Collection#add 32 batch | 2,605 | ±1.93% | 82 |
| Backbone.Collection#add 1024 batch | 86.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 startThen open the http://localhost:3000 in your browser.