updux/src/initialState.ts

17 lines
416 B
TypeScript
Raw Normal View History

2023-09-06 19:09:45 +00:00
import u from '@yanick/updeep-remeda';
import * as R from 'remeda';
export function buildInitialState(localInitialState, subduxes) {
let state = localInitialState ?? {};
if (subduxes) {
if (typeof state !== 'object') {
throw new Error('root initial state is not an object');
}
state = u(state, R.mapValues(subduxes, R.prop('initialState')));
}
return state;
}