createSelector1<S, R1, T> function

Selector<S, T> createSelector1<S, R1, T>(
  1. Selector<S, R1> selector,
  2. T combiner(
    1. R1
    ), {
  3. T Function(R1) memoize(
    1. T (
      1. R1
      )
    )?,
})

Create a memoized selector starting with one selector. It will cache the result of the combiner function, and only recompute when the provided selector delivers new results.

A complete example can be seen as part of the Selector documentation.

Implementation

Selector<S, T> createSelector1<S, R1, T>(
  Selector<S, R1> selector,
  T Function(R1) combiner, {
  T Function(R1) Function(T Function(R1))? memoize,
}) {
  final memoized = (memoize ?? memo1)(combiner);

  return (S state) {
    return memoized(selector(state));
  };
}