mirror of
https://github.com/yldio/copilot.git
synced 2024-12-25 19:30:05 +02:00
8295bd6882
this shall be a progressive process
27 lines
557 B
JavaScript
27 lines
557 B
JavaScript
const takeRight = require('lodash.takeright');
|
|
const redux = require('redux');
|
|
|
|
const {
|
|
createStore,
|
|
compose,
|
|
combineReducers,
|
|
applyMiddleware
|
|
} = redux;
|
|
|
|
const reducer = (state, action) => {
|
|
if (action.type !== 'UPDATE_STATS') {
|
|
return state;
|
|
}
|
|
|
|
const data = (state.data || []).concat([action.payload]);
|
|
|
|
return {
|
|
...state,
|
|
data: takeRight(data, 50)
|
|
};
|
|
};
|
|
|
|
module.exports = (state = Object.freeze({})) => {
|
|
return createStore(reducer, state, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__());
|
|
};
|