Skip to content

v1.0.8

Compare
Choose a tag to compare
@ashish-r ashish-r released this 09 May 12:05
· 16 commits to main since this release

import createGlobalStateSelector from 'create-global-state-selector'

Example:

const store = { a: { b: { x: 55, y: 65, z: 'temp' } } };
  • Pass object of selector functions

    const { selectX, selectY } = createGlobalStateSelector(
      {
        selectX: (state: Record<string, any>): number => state.x,
        selectY: (state: Record<string, any>): number => state.y,
      },
      'a',
      'b'
    );
    
    selectX(store) // 55
    selectY(store) // 65
    
  • Pass one selector function

    const selectZ = createGlobalStateSelector(
      (state: Record<string, any>): number => state.z,
      'a',
      'b'
    );
    
    selectZ(store) // 'temp'