Options
All
  • Public
  • Public/Protected
  • All
Menu

@fp51/store-react - v2.0.1

Index

Type aliases

Options<State>: Partial<{ equals: any }>

Type parameters

  • State

Functions

  • createSelectorHook<State>(getStore: () => Store<State>): <SelectedState>(selector: (state: State) => SelectedState, options?: Partial<{ equals: any }>) => SelectedState
  • Type parameters

    • State

    Parameters

    • getStore: () => Store<State>
        • (): Store<State>
        • Returns Store<State>

    Returns <SelectedState>(selector: (state: State) => SelectedState, options?: Partial<{ equals: any }>) => SelectedState

      • <SelectedState>(selector: (state: State) => SelectedState, options?: Partial<{ equals: any }>): SelectedState
      • Type parameters

        • SelectedState

        Parameters

        • selector: (state: State) => SelectedState
            • (state: State): SelectedState
            • Parameters

              • state: State

              Returns SelectedState

        • Optional options: Partial<{ equals: any }>

        Returns SelectedState

  • createStateHook<State>(getStore: () => Store<State>): (options?: Partial<{ equals: any }>) => State
  • Type parameters

    • State

    Parameters

    • getStore: () => Store<State>
        • (): Store<State>
        • Returns Store<State>

    Returns (options?: Partial<{ equals: any }>) => State

      • (options?: Partial<{ equals: any }>): State
      • Parameters

        • Optional options: Partial<{ equals: any }>

        Returns State

  • useSelector<State, SubState>(selector: (state: State) => SubState, store: Store<State>, options?: Partial<{ equals: any }>): SubState
  • Access store state and apply given selector.

    example

    import React from 'react'; import { useSelector } from 'store-react';

    import { store } from './store';

    export const Component = () => { const message = useSelector(state => state.message, store);

    return

    {message}
    }

    Type parameters

    • State

    • SubState

    Parameters

    • selector: (state: State) => SubState

      Given a state, produces a sub state. Should be pure. A selector returning something new even when state does not change will create infinite loop.

        • (state: State): SubState
        • Parameters

          • state: State

          Returns SubState

    • store: Store<State>

      The store to watch for state changes.

    • options: Partial<{ equals: any }> = {}

      Optional options to customize the way the selected result is handle.

    Returns SubState

  • useState<State>(store: Store<State>, options?: Partial<{ equals: any }>): State
  • Access store state.

    Pass optional options to customize the way the selected result is handle.

    example

    import React from 'react'; import { useState } from 'store-react';

    import { store } from './store';

    export const Component = () => { const state = useState(store);

    return

    {state}
    }

    Type parameters

    • State

    Parameters

    • store: Store<State>

      The store to watch for state changes.

    • Optional options: Partial<{ equals: any }>

      Optional options to customize the way the selected result is handle.

    Returns State

Generated using TypeDoc