ConstThe first argument, often a Redux root state object.
All additional arguments passed into the selector.
A derived value from the state.
Clears the memoization cache associated with a memoized function. This method is typically used to reset the state of the cache, allowing for the garbage collection of previously memoized results and ensuring that future calls to the function recompute the results.
Note: An output selector keeps a separate cache for its arguments
(argsMemoize) and for its result (memoize). Calling clearCache on the
selector only clears the former; to fully reset it, also call
selector.memoizedResultFunc.clearCache().
The array of the input selectors used by createSelector to compose the
combiner (OutputSelectorFields.memoizedResultFunc memoizedResultFunc).
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.
The memoized version of OutputSelectorFields.resultFunc resultFunc.
This holds its own cache, separate from the one attached to the output
selector itself. To fully reset a selector, call clearCache on both
(e.g. selector.clearCache() and selector.memoizedResultFunc.clearCache()).
Counts the number of times OutputSelectorFields.memoizedResultFunc memoizedResultFunc has been recalculated.
Resets the count OutputSelectorFields.dependencyRecomputations dependencyRecomputations for the input selectors (OutputSelectorFields.dependencies dependencies) of a memoized selector.
Resets the count of OutputSelectorFields.recomputations recomputations count to 0.
The final function passed to createSelector. Otherwise known as the combiner.
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 }
)
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.
A function that takes a state and returns data that is based on that state.