updux/src/selectors.ts
2024-08-08 09:28:44 -04:00

11 lines
360 B
TypeScript

import { D } from '@mobily/ts-belt';
export function buildSelectors(localSelectors = {}, subduxes = {}) {
const subSelectors = (Object.entries(subduxes) as any).map(
([slice, { selectors }]) =>
D.map(selectors, (subSelect) => (state) => subSelect(state[slice])),
);
return [localSelectors, ...subSelectors].reduce(D.merge);
}