Skip to content

Commit

Permalink
Update docs site link and tweak content
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Dec 3, 2023
1 parent a5db189 commit 31f2228
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/autotrackMemoize/autotrackMemoize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import { createCache } from './autotracking'
*
* @template Func - The type of the function that is memoized.
*
* @see {@link https://reselect-docs.netlify.app/api/unstable_autotrackMemoize autotrackMemoize}
* @see {@link https://reselect.js.org/api/unstable_autotrackMemoize autotrackMemoize}
*
* @since 5.0.0
* @public
Expand Down
6 changes: 3 additions & 3 deletions src/createSelectorCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export interface CreateSelectorFunction<
* @template MemoizeFunction - The type of the memoize function that is used to memoize the `resultFunc` inside `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`).
* @template ArgsMemoizeFunction - 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.
*
* @see {@link https://reselect-docs.netlify.app/api/createSelectorCreator#using-options-since-500 `createSelectorCreator`}
* @see {@link https://reselect.js.org/api/createSelectorCreator#using-options-since-500 `createSelectorCreator`}
*
* @since 5.0.0
* @public
Expand Down Expand Up @@ -216,7 +216,7 @@ export function createSelectorCreator<
*
* @template MemoizeFunction - The type of the memoize function that is used to memoize the `resultFunc` inside `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`).
*
* @see {@link https://reselect-docs.netlify.app/api/createSelectorCreator#using-memoize-and-memoizeoptions `createSelectorCreator`}
* @see {@link https://reselect.js.org/api/createSelectorCreator#using-memoize-and-memoizeoptions `createSelectorCreator`}
*
* @public
*/
Expand Down Expand Up @@ -435,7 +435,7 @@ export function createSelectorCreator<
* a single "result function" / "combiner", and an optional options object, and
* generates a memoized selector function.
*
* @see {@link https://reselect-docs.netlify.app/api/createSelector `createSelector`}
* @see {@link https://reselect.js.org/api/createSelector `createSelector`}
*
* @public
*/
Expand Down
6 changes: 3 additions & 3 deletions src/createStructuredSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ interface SelectorsObject {
* The structured selector can take multiple input selectors
* and map their output to an object with specific keys.
*
* @see {@link https://reselect-docs.netlify.app/api/createStructuredSelector `createStructuredSelector`}
* @see {@link https://reselect.js.org/api/createStructuredSelector `createStructuredSelector`}
*
* @public
*/
Expand Down Expand Up @@ -136,7 +136,7 @@ export interface StructuredSelectorCreator {
* @template MemoizeFunction - The type of the memoize function that is used to create the structured selector. It defaults to `weakMapMemoize`.
* @template ArgsMemoizeFunction - The type of the of the memoize function that is used to memoize the arguments passed into the generated structured selector. It defaults to `weakMapMemoize`.
*
* @see {@link https://reselect-docs.netlify.app/api/createStructuredSelector `createStructuredSelector`}
* @see {@link https://reselect.js.org/api/createStructuredSelector `createStructuredSelector`}
*/
<
InputSelectorsObject extends SelectorsObject,
Expand Down Expand Up @@ -203,7 +203,7 @@ export interface StructuredSelectorCreator {
* )
* ```
*
* @see {@link https://reselect-docs.netlify.app/api/createStructuredSelector `createStructuredSelector`}
* @see {@link https://reselect.js.org/api/createStructuredSelector `createStructuredSelector`}
*
* @public
*/
Expand Down
2 changes: 1 addition & 1 deletion src/devModeChecks/identityFunctionCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { AnyFunction } from '../types'
*
* @param resultFunc - The result function to be checked.
*
* @see {@link https://reselect-docs.netlify.app/api/development-only-stability-checks#identityfunctioncheck `identityFunctionCheck`}
* @see {@link https://reselect.js.org/api/development-only-stability-checks#identityfunctioncheck `identityFunctionCheck`}
*
* @since 5.0.0
* @internal
Expand Down
2 changes: 1 addition & 1 deletion src/devModeChecks/inputStabilityCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { CreateSelectorOptions, UnknownMemoizer } from '../types'
* @param options - Options object consisting of a `memoize` function and a `memoizeOptions` object.
* @param inputSelectorArgs - List of arguments being passed to the input selectors.
*
* @see {@link https://reselect-docs.netlify.app/api/development-only-stability-checks/#inputstabilitycheck `inputStabilityCheck`}
* @see {@link https://reselect.js.org/api/development-only-stability-checks/#inputstabilitycheck `inputStabilityCheck`}
*
* @since 5.0.0
* @internal
Expand Down
4 changes: 2 additions & 2 deletions src/devModeChecks/setGlobalDevModeChecks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export const globalDevModeChecks: DevModeChecks = {
* // Never run the identity function check.
* setGlobalDevModeChecks({ identityFunctionCheck: 'never' })
* ```
* @see {@link https://reselect-docs.netlify.app/api/development-only-stability-checks Development-Only Stability Checks}
* @see {@link https://reselect-docs.netlify.app/api/development-only-stability-checks#1-globally-through-setglobaldevmodechecks global-configuration}
* @see {@link https://reselect.js.org/api/development-only-stability-checks Development-Only Stability Checks}
* @see {@link https://reselect.js.org/api/development-only-stability-checks#1-globally-through-setglobaldevmodechecks global-configuration}
*
* @since 5.0.0
* @public
Expand Down
2 changes: 1 addition & 1 deletion src/lruMemoize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export interface LruMemoizeOptions<Result = any> {
*
* @template Func - The type of the function that is memoized.
*
* @see {@link https://reselect-docs.netlify.app/api/lruMemoize `lruMemoize`}
* @see {@link https://reselect.js.org/api/lruMemoize `lruMemoize`}
*
* @public
*/
Expand Down
14 changes: 7 additions & 7 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export interface CreateSelectorOptions<
* and warn about potential issues in selector behavior. This option
* allows you to customize the behavior of these checks per selector.
*
* @see {@link https://reselect-docs.netlify.app/api/development-only-stability-checks Development-Only Stability Checks}
* @see {@link https://reselect.js.org/api/development-only-stability-checks Development-Only Stability Checks}
*
* @since 5.0.0
*/
Expand Down Expand Up @@ -315,9 +315,9 @@ export interface DevModeChecks {
*
* @default 'once'
*
* @see {@link https://reselect-docs.netlify.app/api/development-only-stability-checks Development-Only Stability Checks}
* @see {@link https://reselect-docs.netlify.app/api/development-only-stability-checks#inputstabilitycheck `inputStabilityCheck`}
* @see {@link https://reselect-docs.netlify.app/api/development-only-stability-checks#2-per-selector-by-passing-an-inputstabilitycheck-option-directly-to- per-selector-configuration}
* @see {@link https://reselect.js.org/api/development-only-stability-checks Development-Only Stability Checks}
* @see {@link https://reselect.js.org/api/development-only-stability-checks#inputstabilitycheck `inputStabilityCheck`}
* @see {@link https://reselect.js.org/api/development-only-stability-checks#2-per-selector-by-passing-an-inputstabilitycheck-option-directly-to- per-selector-configuration}
*
* @since 5.0.0
*/
Expand All @@ -331,9 +331,9 @@ export interface DevModeChecks {
*
* @default 'once'
*
* @see {@link https://reselect-docs.netlify.app/api/development-only-stability-checks Development-Only Stability Checks}
* @see {@link https://reselect-docs.netlify.app/api/development-only-stability-checks#identityfunctioncheck `identityFunctionCheck`}
* @see {@link https://reselect-docs.netlify.app/api/development-only-stability-checks#2-per-selector-by-passing-an-identityfunctioncheck-option-directly-to- per-selector-configuration}
* @see {@link https://reselect.js.org/api/development-only-stability-checks Development-Only Stability Checks}
* @see {@link https://reselect.js.org/api/development-only-stability-checks#identityfunctioncheck `identityFunctionCheck`}
* @see {@link https://reselect.js.org/api/development-only-stability-checks#2-per-selector-by-passing-an-identityfunctioncheck-option-directly-to- per-selector-configuration}
*
* @since 5.0.0
*/
Expand Down
2 changes: 1 addition & 1 deletion src/weakMapMemoize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export interface WeakMapMemoizeOptions<Result = any> {
*
* @template Func - The type of the function that is memoized.
*
* @see {@link https://reselect-docs.netlify.app/api/weakMapMemoize `weakMapMemoize`}
* @see {@link https://reselect.js.org/api/weakMapMemoize `weakMapMemoize`}
*
* @since 5.0.0
* @public
Expand Down
16 changes: 16 additions & 0 deletions website/docs/api/createSelector.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ Accepts one or more "<InternalLinks.InputSelectors />" (either as separate argum
a single "<InternalLinks.ResultFunction />", and an optional options object, and
generates a memoized selector function.

The **Redux docs usage page on [Deriving Data with Selectors](https://redux.js.org/usage/deriving-data-selectors)** covers the purpose and motivation for selectors, why memoized selectors are useful, and typical Reselect usage patterns.

```ts no-emit
const selectTodosByCategory = createSelector(
[
// Pass input selectors with typed arguments
(state: RootState) => state.todos,
(state: RootState, category: string) => category
],
// Extracted values are passed to the result function for recalculation
(todos, category) => {
return todos.filter(t => t.category === category)
}
)
```

## Parameters

| Name | Description |
Expand Down
4 changes: 2 additions & 2 deletions website/docs/introduction/how-does-reselect-work.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The way Reselect works can be broken down into multiple parts:
- If the results are the same, it returns the cached result without running the <InternalLinks.ResultFunction />.
- If the results differ, it runs the <InternalLinks.ResultFunction />.

This behavior is what we call **_Cascading Double-Layer Memoization_**.
This behavior is what we call **_Cascading Memoization_**.

### Reselect Vs Standard Memoization

Expand Down Expand Up @@ -135,6 +135,6 @@ store.dispatch(toggleRead(0))
selectCompletedTodos(store.getState())
```

Even when the overall `state` changes, Reselect ensures efficient memoization through its unique approach. The <InternalLinks.ResultFunction /> doesn't re-run if the relevant part of the `state` (in this case `state.todos`), remains unchanged. This is due to Reselect's <InternalLinks.CascadingMemoization text="Cascading Double-Layer Memoization" />. The first layer checks the entire `state`, and the second layer checks the results of the <InternalLinks.InputSelectors />. If the first layer fails (due to a change in the overall `state`) but the second layer succeeds (because `state.todos` is unchanged), Reselect skips recalculating the <InternalLinks.ResultFunction />. This dual-check mechanism makes Reselect particularly effective in <ExternalLinks.Redux /> applications, ensuring computations are only done when truly necessary.
Even when the overall `state` changes, Reselect ensures efficient memoization through its unique approach. The <InternalLinks.ResultFunction /> doesn't re-run if the relevant part of the `state` (in this case `state.todos`), remains unchanged. This is due to Reselect's <InternalLinks.CascadingMemoization text="Cascading Memoization" />. The first layer checks the entire `state`, and the second layer checks the results of the <InternalLinks.InputSelectors />. If the first layer fails (due to a change in the overall `state`) but the second layer succeeds (because `state.todos` is unchanged), Reselect skips recalculating the <InternalLinks.ResultFunction />. This dual-check mechanism makes Reselect particularly effective in <ExternalLinks.Redux /> applications, ensuring computations are only done when truly necessary.

---
4 changes: 1 addition & 3 deletions website/src/components/InternalLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ export const InternalLinks = {
to="/introduction/how-does-reselect-work#cascading-memoization"
title="Cascading Memoization"
>
<b>
<i>{text}</i>
</b>
"{text}"
</Link>
)),
OutputSelectorFields: memo(({ text = 'Output Selector Fields' }) => (
Expand Down

0 comments on commit 31f2228

Please sign in to comment.