mirror of
https://github.com/yldio/copilot.git
synced 2024-12-01 07:30:07 +02:00
26 lines
460 B
JavaScript
26 lines
460 B
JavaScript
|
const takeRight = require('lodash.takeright');
|
||
|
const redux = require('redux');
|
||
|
|
||
|
const {
|
||
|
createStore,
|
||
|
compose,
|
||
|
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);
|
||
|
};
|