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:
15
shared/naturalcrit/brew.actions.js
Normal file
15
shared/naturalcrit/brew.actions.js
Normal 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;
|
||||
31
shared/naturalcrit/brew.store.js
Normal file
31
shared/naturalcrit/brew.store.js
Normal 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;
|
||||
Reference in New Issue
Block a user