Skip to content

Releases: ashish-r/create-global-state-selector

v1.1.3

10 May 17:46
5e818c3
Compare
Choose a tag to compare

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'

v1.1.2

10 May 12:26
ce0d968
Compare
Choose a tag to compare

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 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'
    

v1.1.1

09 May 17:25
4118711
Compare
Choose a tag to compare

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 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'
    

v1.1.0

09 May 17:11
ffe4284
Compare
Choose a tag to compare

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'
    

v1.0.8

09 May 12:05
Compare
Choose a tag to compare

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'