21 lines
604 B
TypeScript
21 lines
604 B
TypeScript
|
export function buildActions(actions = {}, subduxes = {}) {
|
||
|
// priority => generics => generic subs => craft subs => creators
|
||
|
|
||
|
const merged = { ...actions };
|
||
|
|
||
|
Object.values(subduxes).forEach(({ actions }) => {
|
||
|
if (!actions) return;
|
||
|
Object.entries(actions).forEach(([type, func]) => {
|
||
|
if (merged[type]) {
|
||
|
if (merged[type] === func) return;
|
||
|
throw new Error(
|
||
|
`trying to merge two different actions ${type}`
|
||
|
);
|
||
|
}
|
||
|
|
||
|
merged[type] = func;
|
||
|
});
|
||
|
});
|
||
|
return merged;
|
||
|
}
|