What's New?
Documentation update.
Uses:
import `createGlobalStateSelector` from 'create-global-state-selector'
Example:
const store = { a: { b: { x: 55, y: 65, z: 'temp' } } };
Pass an object of local slice selectors
const { selectX, selectY, selectZ } = createGlobalStateSelector(
{
selectX: (state: Record<string, any>): number => state.x,
selectY: (state: Record<string, any>): number => state.y,
selectZ: (state: Record<string, any>): string => state.z
},
'a',
'b'
);
// Final store signature after combineReducers
const store = { a: { b: { x: 55, y: 65, z: 'temp' } } };
selectX(store); // 55
selectY(store); // 65
selectZ(store); // 'temp'
Pass a local slice selector
const selectZ = createGlobalStateSelector((state: Record<string, any>): number => state.z, 'a', 'b');
// Final store signature after combineReducers
const store = { a: { b: { x: 55, y: 65, z: 'temp' } } };
selectZ(store); // 'temp'