FluxDux
The best of both FLUX and Redux all in one package.
Description
This library is a mixture of both FLUX and Redux's features. Each store
will only be keeping its own data state, the state is reduced through store.reduce
method. Store does not listen directly to actions, but through an immediate object called the handler
. These handler
s will listen to actions
that being dispatched from view
.
For more detail explaination, please follow this tutorial.
Install
Install directly from npm using command-line.
npm install --save fluxdux
Or checkout from github
git clone https://github.com/nquangtrung/fluxdux
Usage
Please see demo/demo.js
for some quick usage example.
Define store
with its reducers.
var FluxDux = require('../fluxdux.js');
var store = FluxDux.createStore('notes', {
initialState : function() { ... },
add : function(state, data) {
return newState;
},
delete : function(state, data) {
return newState;
},
});
Define actions
.
var actions = FluxDux.createActions(
[ "add", "delete" ]
);
How handler
will connect action
and store
FluxDux.handle(actions, {
add : function(data) {
store.reduce("add", data);
},
delete : function(data) {
store.reduce("delete", data);
}
});
Actions can be dispatched through directly calling the method.
actions.add({ text: "text1", author: "author1" });
actions.delete({ index: 1 });
actions.add({ text: "text2", author: "author2" });
NPM package