• A function that takes a state and returns data that is based on that state.

    Parameters

    • state: {
          connection: ConnectionState;
          crm: CrmState & PersistPartial;
          messages: MessagesState & PersistPartial;
          organizations: OrganizationsState;
          persons: PersonsState;
          reasons: ReasonsState;
          sector: SectorState & PersistPartial;
          service: ServiceState;
          session: SessionState;
          settings: SettingsState & PersistPartial;
          tags: TagsState;
          tasks: TasksState;
          template: TemplateState;
          user: UserState & PersistPartial;
          users: UsersState;
          workspace: WorkspaceState & PersistPartial;
      }

      The first argument, often a Redux root state object.

    • ...params: []

      All additional arguments passed into the selector.

    Returns I18n

    A derived value from the state.

Properties

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

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.

Type declaration

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

      Creates a tree of WeakMap-based cache nodes based on the identity of the arguments it's been called with (in this case, the extracted values from your input selectors). This allows weakMapMemoize to have an effectively infinite cache size. Cache results will be kept in memory as long as references to the arguments still exist, and then cleared out as the arguments are garbage-collected.

      Design Tradeoffs for weakMapMemoize:

      • Pros:
        • It has an effectively infinite cache size, but you have no control over how long values are kept in cache as it's based on garbage collection and WeakMaps.
      • Cons:
        • There's currently no way to alter the argument comparisons. They're based on strict reference equality.
        • It's roughly the same speed as lruMemoize, although likely a fraction slower.

      Use Cases for weakMapMemoize:

      • This memoizer is likely best used for cases where you need to call the same selector instance with many different arguments, such as a single selector instance that is used in a list item component and called with item IDs like:
        useSelector(state => selectSomeData(state, props.category))
        

      Type Parameters

      • Func extends AnyFunction

        The type of the function that is memoized.

      Parameters

      • func: Func

        The function to be memoized.

      • Optionaloptions: WeakMapMemoizeOptions<ReturnType<Func>>

      Returns Func & {
          clearCache: () => void;
          resetResultsCount: () => void;
          resultsCount: () => number;
      }

      A memoized function with a .clearCache() method attached.

      Using `createSelector` ```ts import { createSelector, weakMapMemoize } from 'reselect'

      interface RootState { items: { id: number; category: string; name: string }[] }

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

      
      
      Using `createSelectorCreator` ```ts import { createSelectorCreator, weakMapMemoize } from 'reselect'

      const createSelectorWeakMap = createSelectorCreator({ memoize: weakMapMemoize, argsMemoize: weakMapMemoize })

      const selectItemsByCategory = createSelectorWeakMap( [ (state: RootState) => state.items, (state: RootState, category: string) => category ], (items, category) => items.filter(item => item.category === category) )

      
      

      5.0.0

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

clearCache: () => void
dependencies: [
    (
        state: {
            connection: ConnectionState;
            crm: CrmState & PersistPartial;
            messages: MessagesState & PersistPartial;
            organizations: OrganizationsState;
            persons: PersonsState;
            reasons: ReasonsState;
            sector: SectorState & PersistPartial;
            service: ServiceState;
            session: SessionState;
            settings: SettingsState & PersistPartial;
            tags: TagsState;
            tasks: TasksState;
            template: TemplateState;
            user: UserState & PersistPartial;
            users: UsersState;
            workspace: WorkspaceState & PersistPartial;
        },
    ) => "pt-BR"
    | "en"
    | "fr"
    | "es",
]

The array of the input selectors used by createSelector to compose the combiner (OutputSelectorFields.memoizedResultFunc memoizedResultFunc).

dependencyRecomputations: () => number

Counts the number of times the input selectors (OutputSelectorFields.dependencies dependencies) have been recalculated. This is distinct from OutputSelectorFields.recomputations recomputations, which tracks the recalculations of the result function.

5.0.0

lastResult: () => I18n

The last result calculated by OutputSelectorFields.memoizedResultFunc memoizedResultFunc.

memoize: <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.

Type declaration

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

      Creates a tree of WeakMap-based cache nodes based on the identity of the arguments it's been called with (in this case, the extracted values from your input selectors). This allows weakMapMemoize to have an effectively infinite cache size. Cache results will be kept in memory as long as references to the arguments still exist, and then cleared out as the arguments are garbage-collected.

      Design Tradeoffs for weakMapMemoize:

      • Pros:
        • It has an effectively infinite cache size, but you have no control over how long values are kept in cache as it's based on garbage collection and WeakMaps.
      • Cons:
        • There's currently no way to alter the argument comparisons. They're based on strict reference equality.
        • It's roughly the same speed as lruMemoize, although likely a fraction slower.

      Use Cases for weakMapMemoize:

      • This memoizer is likely best used for cases where you need to call the same selector instance with many different arguments, such as a single selector instance that is used in a list item component and called with item IDs like:
        useSelector(state => selectSomeData(state, props.category))
        

      Type Parameters

      • Func extends AnyFunction

        The type of the function that is memoized.

      Parameters

      • func: Func

        The function to be memoized.

      • Optionaloptions: WeakMapMemoizeOptions<ReturnType<Func>>

      Returns Func & {
          clearCache: () => void;
          resetResultsCount: () => void;
          resultsCount: () => number;
      }

      A memoized function with a .clearCache() method attached.

      Using `createSelector` ```ts import { createSelector, weakMapMemoize } from 'reselect'

      interface RootState { items: { id: number; category: string; name: string }[] }

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

      
      
      Using `createSelectorCreator` ```ts import { createSelectorCreator, weakMapMemoize } from 'reselect'

      const createSelectorWeakMap = createSelectorCreator({ memoize: weakMapMemoize, argsMemoize: weakMapMemoize })

      const selectItemsByCategory = createSelectorWeakMap( [ (state: RootState) => state.items, (state: RootState, category: string) => category ], (items, category) => items.filter(item => item.category === category) )

      
      

      5.0.0

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

memoizedResultFunc: (...resultFuncArgs: ["pt-BR" | "en" | "fr" | "es"]) => I18n & {
    clearCache: () => void;
    resetResultsCount: () => void;
    resultsCount: () => number;
}

Type declaration

    • (...resultFuncArgs: ["pt-BR" | "en" | "fr" | "es"]): I18n
    • A function that takes input selectors' return values as arguments and returns a result. Otherwise known as resultFunc.

      Parameters

      • ...resultFuncArgs: ["pt-BR" | "en" | "fr" | "es"]

        Return values of input selectors.

      Returns I18n

      The return value of OutputSelectorFields.resultFunc resultFunc.

  • clearCache: () => void
  • resetResultsCount: () => void
  • resultsCount: () => number
recomputations: () => number

Counts the number of times OutputSelectorFields.memoizedResultFunc memoizedResultFunc has been recalculated.

resetDependencyRecomputations: () => void

5.0.0

resetRecomputations: () => void
resetResultsCount: () => void
resultFunc: (...resultFuncArgs: ["pt-BR" | "en" | "fr" | "es"]) => I18n

The final function passed to createSelector. Otherwise known as the combiner.

Type declaration

    • (...resultFuncArgs: ["pt-BR" | "en" | "fr" | "es"]): I18n
    • A function that takes input selectors' return values as arguments and returns a result. Otherwise known as resultFunc.

      Parameters

      • ...resultFuncArgs: ["pt-BR" | "en" | "fr" | "es"]

        Return values of input selectors.

      Returns I18n

      The return value of OutputSelectorFields.resultFunc resultFunc.

resultsCount: () => number