1.0.0-alpha-1 • Published 8 years ago
store-state v1.0.0-alpha-1
Flux Data Store
This is a datastore intended for use with a Flux/Redux base architecture. Instead of calling each reducer, you subscribe to an individual event type, reducing the code that is run on each event.
Usage
$ npm install --save store-state
// Create the store
var store = new Store({} /* Initial state */);
// Subscribe to an action
store.subscribe('updateTime', function (state) {
return Object.assign({}, state, {
time: new Date()
});
});
// Re-render on changes
store.on('changed', function (state) {
// Do stuff based on the updated store-state
// Like update the views, maybe with react.render...
// `state` is the updated state after the reducers are run
});
More to come....
1.0.0-alpha-1
8 years ago