Selector<State, V> typedef

Selector<State, V> = V Function(State state)

Inspirited by NgRx memoized selector

  • Selectors can compute derived data, to store the minimal possible state.
  • Selectors are efficient. A selector is not recomputed unless one of its arguments changes.
  • When using the select, select2 to select9, selectMany functions, keeps track of the latest arguments in which your selector function was invoked. Because selectors are pure functions, the last result can be returned when the arguments match without re-invoking your selector function. This can provide performance benefits, particularly with selectors that perform expensive computation. This practice is known as memoization.

Implementation

typedef Selector<State, V> = V Function(State state);