beau-flux
v0.2.1
Published
BeauFlux =========
Downloads
3
Readme
BeauFlux
Simple Reactive Flux implementation
Usage
import { Action, Store, MultiStore } from 'beau-flux';
const additionAction = new Action();
const subtractionAction = new Action();
const multiplicationAction = new Action();
class MathStore extends Store {
constructor() {
super(0, [
{ action: additionAction, response: (state, payload) => state + payload },
{ action: subtractionAction, response: (state, payload) => state - payload },
{ action: multiplicationAction, response: (state, payload) => state * payload }
]);
}
};
const mathStore = new MathStore();
const mathStoreState = mathStore.register(newState => console.log(newState));
const concatAction = new Action();
class MultiStringStore extends MultiStore {
constructor() {
super('', [
{ action: concatAction,
map: {key, value} => {key:key, payload:value},
response: (state, payload) => state + payload }
]);
}
};
const multiStringStore = new MultiStringStore();
const stringState = multiStringStore.register(0, newState => console.log(newState));
Tests
npm test