Simple container of unidirectional data flow.
npm install fluxter






Fluxter is a simple container of unidirectional data flow.
```
$ npm install --save fluxter
Add reducer to store
Add middleware to store
Add action to store
Dispatch action to store
Add handler
Call next middleware or done
Example
`js`
let store = new Fluxter({
user: {
logged: false,
name: null,
token: null
}
});
Kind: global function
| Param | Type | Description |
| --- | --- | --- |
| stateKey | String | A state field |
| reducer | function | A pure function |
Example
`js`
store.addReducer('user', (state = {}, actionName, actionData) => {
if (actionName === 'login') {
return {
...state,
logged: actionData.logged,
name: actionData.name,
token: actionData.token
};
}
return state;
});
Kind: global function
| Param | Type | Description |
| --- | --- | --- |
| middleware | function | A middleware function |
Example
`js`
store.addMiddleware('user', (store, actionName, actionData, next) => {
if (actionName === 'login') {
SomeRepository.check(actionData).then(data => next({
...data,
...actionData
}));
} else {
next(actionData);
}
});
Kind: global function
| Param | Type | Description |
| --- | --- | --- |
| actionName | String | An action name |
| action | function | An action creator function |
Example
`js`
store.addAction('login', (name, password) => ({
name,
password
}));
Kind: global function
| Param | Type | Description |
| --- | --- | --- |
| actionName | String | An action name |
| ...args | \* | Arguments that take action |
Example
`js`
store.dispatch('login', 'example-name', 'example-password');
Kind: global function
| Param | Type | Description |
| --- | --- | --- |
| handler | function | Change state handler |
Example
`js``
store.subscribe(store => view.setState(store.state));
Kind: global function
| Param | Type | Description |
| --- | --- | --- |
| actionData | \* | An action data |

Online game SeaWars. Example of using Fluxter.
1. Fork the project.
2. Make your feature addition or bug fix.
3. Send me a pull request.
*
© 2017 Vasily Shilov