@laserware/stasis
    Preparing search index...

    Function createSelectorCreator

    • Creates a selector creator function with the specified memoization function and options for customizing memoization behavior.

      Type Parameters

      • MemoizeFunction extends UnknownMemoizer<UnknownFunction>

        The type of the memoize function that is used to memoize the resultFunc inside createSelector (e.g., lruMemoize or weakMapMemoize).

      • ArgsMemoizeFunction extends UnknownMemoizer<UnknownFunction> = <Func extends AnyFunction>(
            func: Func,
            options?: WeakMapMemoizeOptions<ReturnType<Func>>,
        ) => Func & {
            clearCache: () => void;
            resetResultsCount: () => void;
            resultsCount: () => number;
        }

        The type of the optional memoize function that is used to memoize the arguments passed into the output selector generated by createSelector (e.g., lruMemoize or weakMapMemoize). If none is explicitly provided, weakMapMemoize will be used.

      Parameters

      • options: {
            argsMemoize?: IfNever<
                ArgsMemoizeFunction,
                <Func extends AnyFunction>(
                    func: Func,
                    options?: WeakMapMemoizeOptions<ReturnType<Func>>,
                ) => Func & {
                    clearCache: () => void;
                    resetResultsCount: () => void;
                    resultsCount: () => number;
                },
                ArgsMemoizeFunction,
            >;
            argsMemoizeOptions?: IfNever<
                ArgsMemoizeFunction,
                | undefined
                | { resultEqualityCheck?: EqualityFn<any> }
                | (undefined | { resultEqualityCheck?: EqualityFn<any> })[],

                    | Simplify<
                        Simplify<
                            OmitIndexSignature<
                                Exclude<DropFirstParameter<ArgsMemoizeFunction>[0], AnyFunction>,
                            >,
                        >,
                    >
                    | Simplify<
                        Extract<DropFirstParameter<ArgsMemoizeFunction>[0], AnyFunction>,
                    >
                    | (
                        | Simplify<
                            OmitIndexSignature<
                                Exclude<DropFirstParameter<(...)>[number], AnyFunction>,
                            >,
                        >
                        | Extract<DropFirstParameter<ArgsMemoizeFunction>[number], AnyFunction>
                    )[],
            >;
            devModeChecks?: Partial<DevModeChecks>;
            memoize: IfNever<
                MemoizeFunction,
                <Func extends AnyFunction>(
                    func: Func,
                    options?: WeakMapMemoizeOptions<ReturnType<Func>>,
                ) => Func & {
                    clearCache: () => void;
                    resetResultsCount: () => void;
                    resultsCount: () => number;
                },
            >;
            memoizeOptions?: IfNever<
                MemoizeFunction,
                | undefined
                | { resultEqualityCheck?: EqualityFn<any> }
                | (undefined | { resultEqualityCheck?: EqualityFn<any> })[],

                    | Simplify<
                        Simplify<
                            OmitIndexSignature<
                                Exclude<DropFirstParameter<MemoizeFunction>[0], AnyFunction>,
                            >,
                        >,
                    >
                    | Simplify<Extract<DropFirstParameter<MemoizeFunction>[0], AnyFunction>>
                    | (
                        | Simplify<
                            OmitIndexSignature<
                                Exclude<DropFirstParameter<(...)>[number], AnyFunction>,
                            >,
                        >
                        | Extract<DropFirstParameter<MemoizeFunction>[number], AnyFunction>
                    )[],
            >;
        }

        An options object containing the memoize function responsible for memoizing the resultFunc inside createSelector (e.g., lruMemoize or weakMapMemoize). It also provides additional options for customizing memoization. While the memoize property is mandatory, the rest are optional.

        • OptionalargsMemoize?: IfNever<
              ArgsMemoizeFunction,
              <Func extends AnyFunction>(
                  func: Func,
                  options?: WeakMapMemoizeOptions<ReturnType<Func>>,
              ) => Func & {
                  clearCache: () => void;
                  resetResultsCount: () => void;
                  resultsCount: () => number;
              },
              ArgsMemoizeFunction,
          >

          The optional memoize function that is used to memoize the arguments passed into the output selector generated by createSelector (e.g., lruMemoize or weakMapMemoize).

          When passed directly into createSelector, it overrides the argsMemoize function initially passed into createSelectorCreator. If none was initially provided, weakMapMemoize will be used.

          import { createSelector, weakMapMemoize } from 'reselect'

          const selectItemsByCategory = createSelector(
          [
          (state: RootState) => state.items,
          (state: RootState, category: string) => category
          ],
          (items, category) => items.filter(item => item.category === category),
          { argsMemoize: weakMapMemoize }
          )
          weakMapMemoize
          

          5.0.0

        • OptionalargsMemoizeOptions?: IfNever<
              ArgsMemoizeFunction,
              | undefined
              | { resultEqualityCheck?: EqualityFn<any> }
              | (undefined | { resultEqualityCheck?: EqualityFn<any> })[],

                  | Simplify<
                      Simplify<
                          OmitIndexSignature<
                              Exclude<DropFirstParameter<ArgsMemoizeFunction>[0], AnyFunction>,
                          >,
                      >,
                  >
                  | Simplify<
                      Extract<DropFirstParameter<ArgsMemoizeFunction>[0], AnyFunction>,
                  >
                  | (
                      | Simplify<
                          OmitIndexSignature<
                              Exclude<DropFirstParameter<(...)>[number], AnyFunction>,
                          >,
                      >
                      | Extract<DropFirstParameter<ArgsMemoizeFunction>[number], AnyFunction>
                  )[],
          >

          Optional configuration options for the CreateSelectorOptions.argsMemoize argsMemoize function. These options are passed to the CreateSelectorOptions.argsMemoize argsMemoize function as the second argument.

          5.0.0

        • OptionaldevModeChecks?: Partial<DevModeChecks>

          Reselect performs additional checks in development mode to help identify and warn about potential issues in selector behavior. This option allows you to customize the behavior of these checks per selector.

        • memoize: IfNever<
              MemoizeFunction,
              <Func extends AnyFunction>(
                  func: Func,
                  options?: WeakMapMemoizeOptions<ReturnType<Func>>,
              ) => Func & {
                  clearCache: () => void;
                  resetResultsCount: () => void;
                  resultsCount: () => number;
              },
          >

          The memoize function that is used to memoize the OutputSelectorFields.resultFunc resultFunc inside createSelector (e.g., lruMemoize or weakMapMemoize).

          When passed directly into createSelector, it overrides the memoize function initially passed into createSelectorCreator.

          import { createSelector, weakMapMemoize } from 'reselect'

          const selectItemsByCategory = createSelector(
          [
          (state: RootState) => state.items,
          (state: RootState, category: string) => category
          ],
          (items, category) => items.filter(item => item.category === category),
          { memoize: weakMapMemoize }
          )

          5.0.0

        • OptionalmemoizeOptions?: IfNever<
              MemoizeFunction,
              | undefined
              | { resultEqualityCheck?: EqualityFn<any> }
              | (undefined | { resultEqualityCheck?: EqualityFn<any> })[],

                  | Simplify<
                      Simplify<
                          OmitIndexSignature<
                              Exclude<DropFirstParameter<MemoizeFunction>[0], AnyFunction>,
                          >,
                      >,
                  >
                  | Simplify<Extract<DropFirstParameter<MemoizeFunction>[0], AnyFunction>>
                  | (
                      | Simplify<
                          OmitIndexSignature<
                              Exclude<DropFirstParameter<(...)>[number], AnyFunction>,
                          >,
                      >
                      | Extract<DropFirstParameter<MemoizeFunction>[number], AnyFunction>
                  )[],
          >

          Optional configuration options for the CreateSelectorOptions.memoize memoize function. These options are passed to the CreateSelectorOptions.memoize memoize function as the second argument.

          5.0.0

      Returns CreateSelectorFunction<MemoizeFunction, ArgsMemoizeFunction>

      A customized createSelector function.

      const customCreateSelector = createSelectorCreator({
      memoize: customMemoize, // Function to be used to memoize `resultFunc`
      memoizeOptions: [memoizeOption1, memoizeOption2], // Options passed to `customMemoize` as the second argument onwards
      argsMemoize: customArgsMemoize, // Function to be used to memoize the selector's arguments
      argsMemoizeOptions: [argsMemoizeOption1, argsMemoizeOption2] // Options passed to `customArgsMemoize` as the second argument onwards
      })

      const customSelector = customCreateSelector(
      [inputSelector1, inputSelector2],
      resultFunc // `resultFunc` will be passed as the first argument to `customMemoize`
      )

      customSelector(
      ...selectorArgs // Will be memoized by `customArgsMemoize`
      )

      5.0.0

    • Creates a selector creator function with the specified memoization function and options for customizing memoization behavior.

      Type Parameters

      • MemoizeFunction extends UnknownMemoizer<UnknownFunction>

        The type of the memoize function that is used to memoize the resultFunc inside createSelector (e.g., lruMemoize or weakMapMemoize).

      Parameters

      • memoize: MemoizeFunction

        The memoize function responsible for memoizing the resultFunc inside createSelector (e.g., lruMemoize or weakMapMemoize).

      • ...memoizeOptionsFromArgs: DropFirstParameter<MemoizeFunction>

        Optional configuration options for the memoization function. These options are then passed to the memoize function as the second argument onwards.

      Returns CreateSelectorFunction<MemoizeFunction>

      A customized createSelector function.

      const customCreateSelector = createSelectorCreator(customMemoize, // Function to be used to memoize `resultFunc`
      option1, // Will be passed as second argument to `customMemoize`
      option2, // Will be passed as third argument to `customMemoize`
      option3 // Will be passed as fourth argument to `customMemoize`
      )

      const customSelector = customCreateSelector(
      [inputSelector1, inputSelector2],
      resultFunc // `resultFunc` will be passed as the first argument to `customMemoize`
      )