mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-23 17:47:24 +00:00
10 lines
397 B
JavaScript
10 lines
397 B
JavaScript
// util for creating reducers
|
|
// based off of redux-actions
|
|
// https://redux-actions.js.org/docs/api/handleAction.html#handleactions
|
|
export const handleActions = (actionMap, defaultState) => {
|
|
return (state = defaultState, action) => {
|
|
const handler = actionMap[action.type];
|
|
const newState = handler ? handler(state, action) : {};
|
|
return Object.assign({}, state, newState);
|
|
};
|
|
};
|