0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-13 06:32:39 +00:00

Updating libs and adding basic flux

This commit is contained in:
Scott Tolksdorf
2016-12-26 13:47:49 -05:00
parent cc8e874ad1
commit 7581d155a6
3 changed files with 50 additions and 4 deletions

View File

@@ -0,0 +1,15 @@
const dispatch = require('pico-flux').dispatch;
const Actions = {
addInc : (val = 1) => {
dispatch('ADD_INC', val);
},
delayInc : (val = 1) => {
dispatch('DELAY_INC', val)
},
setInc : (newInc) => {
dispatch('SET_INC', newInc);
},
};
module.exports = Actions;

View File

@@ -0,0 +1,31 @@
const _ = require('lodash');
const flux = require('pico-flux');
let State = {
count : 0
};
const Store = flux.createStore({
INC : (val) => {
State.count += val;
},
SET_INC : (val) => {
State.count = val;
return false;
},
DELAY_INC : (val) => {
setTimeout(()=>{
State.count += val;
Store.emitChange();
}, 2000);
return false;
}
});
Store.getCount = ()=>{
return State.count;
};
module.exports = Store;