Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Docs for v5 changes. #636

Merged
merged 52 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
ea1894e
Update JSDocs for `createStructuredSelector`
aryaemami59 Nov 1, 2023
15feb03
Add units tests to showcase `createStructuredSelector`s second functi…
aryaemami59 Nov 1, 2023
e4fe262
Add more type tests
aryaemami59 Nov 1, 2023
f8cdab2
Fix `README` for v5.
aryaemami59 Nov 11, 2023
acb1c9d
Add `testUtils` file
aryaemami59 Nov 11, 2023
94fef76
Add `createCurriedSelector`
aryaemami59 Nov 11, 2023
93820c6
Fix issues with topic expansion in docs.
aryaemami59 Nov 11, 2023
8db66aa
Merge https://github.com/reduxjs/reselect into v5-docs
aryaemami59 Nov 11, 2023
212e889
Resolve merge conflicts
aryaemami59 Nov 11, 2023
c6dab42
Fix docs for selectors that take arguments
aryaemami59 Nov 11, 2023
5b30a5a
Add `@typescript/analyze-trace` to `devDependencies`
aryaemami59 Nov 13, 2023
d2987bd
Create separate `NPM` command for `@typescript/analyze-trace`
aryaemami59 Nov 13, 2023
1e091af
Add JSDocs for `MergeParameters`.
aryaemami59 Nov 13, 2023
5ff1968
Fix TS bug related to `OutputSelector`.
aryaemami59 Nov 13, 2023
7201083
Add JSDocs for `createCurriedSelector`
aryaemami59 Nov 13, 2023
12e2411
Fix toggle sections in `README`
aryaemami59 Nov 13, 2023
7e22290
Fix `TypedCreateSelector` in `README`
aryaemami59 Nov 13, 2023
bb82bf3
Add `createCurriedSelectorCreator` to docs.
aryaemami59 Nov 13, 2023
3b793a3
Fix library names formatting in docs
aryaemami59 Nov 15, 2023
bdf43e5
Fix API collapsed sections
aryaemami59 Nov 15, 2023
0112f1a
Remove `ParametricSelector` and `OutputParametricSelector`
aryaemami59 Nov 15, 2023
9f7c288
Remove `ParametricSelector` and `OutputParametricSelector` from type …
aryaemami59 Nov 15, 2023
76ad4fa
Remove `connect` reference from `createStructuredSelector` descriptio…
aryaemami59 Nov 15, 2023
dfe31f4
Move `createSelectorCreator` to be directly after `createSelector` in…
aryaemami59 Nov 15, 2023
55361f3
Remove duplicate explanation in the `autotrackMemoize` section in docs.
aryaemami59 Nov 15, 2023
b0fae92
Rename `autotrackMemoize` to `unstable_autotrackMemoize` in examples …
aryaemami59 Nov 15, 2023
af90f43
Add experimental warning label to `unstable_autotrackMemoize` in docs.
aryaemami59 Nov 15, 2023
1a5c72b
Fix `weakMapMemoize` examples.
aryaemami59 Nov 15, 2023
1768c20
Fix JSDocs for `weakMapMemoize`.
aryaemami59 Nov 15, 2023
191614c
Tweak example titles for memoize functions in docs.
aryaemami59 Nov 15, 2023
917afa2
Replace `createCurriedSelector` API with copy paste pattern in docs.
aryaemami59 Nov 15, 2023
de37737
Slightly Modify `createParametricSelectorHook` in docs
aryaemami59 Nov 18, 2023
38e7a40
Fix installation guide in docs
aryaemami59 Nov 18, 2023
3845404
Modify example for `createStructuredSelector` in docs.
aryaemami59 Nov 18, 2023
4458991
Add explanation underneath "How Does Reselect Work" in docs.
aryaemami59 Nov 18, 2023
4bb0655
Modify JSDocs for `createStructuredSelector` to match the docs.
aryaemami59 Nov 18, 2023
3871ae4
Update `createStructuredSelector` link in docs
aryaemami59 Nov 19, 2023
04d8241
Update `examples.test.ts` to match the docs.
aryaemami59 Nov 19, 2023
55ca12e
Add `dependencyRecomputations` and `resetDependencyRecomputations` to…
aryaemami59 Nov 19, 2023
3912374
Fix title of tests in `weakmapMemoize.spec.ts`.
aryaemami59 Nov 19, 2023
6f94ea7
Add "esModuleInterop" to tsconfig for vitest type tests.
aryaemami59 Nov 19, 2023
a031621
Add initial vitest type tests for `createSelectorCreator` and `create…
aryaemami59 Nov 19, 2023
7215304
Fix benchmarks for `orderOfExecution.bench.ts` and `weakMapMemoize.be…
aryaemami59 Nov 19, 2023
4595ef6
Update `yarn.lock`.
aryaemami59 Nov 19, 2023
3de5110
Remove changes unrelated to docs.
aryaemami59 Nov 19, 2023
97b73eb
Update lockfile
aryaemami59 Nov 19, 2023
ecd40bc
Remove other changes not related to docs
aryaemami59 Nov 19, 2023
2d6a4dd
Merge branch 'reduxjs:master' into v5-docs
aryaemami59 Nov 19, 2023
42dad9a
Fix links in JSDocs to match links in`README`
aryaemami59 Nov 20, 2023
999ca66
Remove some details wrappers and add additional descriptions
markerikson Nov 21, 2023
47fd0b5
Tweak TOC
markerikson Nov 21, 2023
c536318
Remove "Top-Level Selectors" since createSlice handles this in RTK 2.0
markerikson Nov 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ typescript_test/common.js
flow_test/should_fail/flow-typed/index.js.flow
flow_test/should_pass/flow-typed/index.js.flow
reselect-builds/

trace

typesversions
.cache
Expand All @@ -24,4 +24,4 @@ typesversions
!.yarn/sdks
!.yarn/versions
.pnp.*
*.tgz
*.tgz
2,165 changes: 1,650 additions & 515 deletions README.md

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions docs/assets/diagrams/normal-memoization-function.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<mxfile host="65bd71144e" scale="1" border="0">
<diagram id="s5zgOlhoY8HzJwKQ5w-s" name="Page-1">
<mxGraphModel dx="1244" dy="636" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="2000" pageHeight="2000" background="#C7FFFB" math="0" shadow="1">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="7" value="" style="group;aspect=fixed;shadow=1;" vertex="1" connectable="0" parent="1">
<mxGeometry x="60" y="460" width="681.5" height="290" as="geometry"/>
</mxCell>
<mxCell id="2" value="Are arguments same as last time?" style="whiteSpace=wrap;html=1;rounded=1;shadow=1;aspect=fixed;" parent="7" vertex="1">
<mxGeometry x="250" y="20" width="150" height="80" as="geometry"/>
</mxCell>
<mxCell id="3" value="Return result." style="whiteSpace=wrap;html=1;rounded=1;shadow=1;" parent="7" vertex="1">
<mxGeometry x="460" y="180" width="110" height="60" as="geometry"/>
</mxCell>
<object label="Yes" id="4">
<mxCell style="edgeStyle=none;html=1;entryX=0;entryY=0;entryDx=0;entryDy=0;shadow=1;" parent="7" source="2" target="3" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
</object>
<mxCell id="5" value="Run function again." style="whiteSpace=wrap;html=1;rounded=1;shadow=1;" parent="7" vertex="1">
<mxGeometry x="30" y="180" width="150" height="60" as="geometry"/>
</mxCell>
<mxCell id="6" value="No" style="edgeStyle=none;html=1;entryX=1;entryY=0;entryDx=0;entryDy=0;shadow=1;" parent="7" source="2" target="5" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="8" value="Untitled Layer" parent="0"/>
</root>
</mxGraphModel>
</diagram>
</mxfile>
40 changes: 40 additions & 0 deletions docs/assets/diagrams/reselect-memoization.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<mxfile host="65bd71144e">
<diagram id="hFjyuBP9kS8yiWHOacYP" name="Page-1">
<mxGraphModel dx="792" dy="1668" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" background="#C7FFFB" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="15" value="" style="group" vertex="1" connectable="0" parent="1">
<mxGeometry x="70" y="-110" width="930" height="440" as="geometry"/>
</mxCell>
<mxCell id="2" value="Are arguments same as last time?" style="whiteSpace=wrap;html=1;rounded=1;shadow=1;" parent="15" vertex="1">
<mxGeometry x="470.735" y="35.2" width="139.57750000000001" height="58.036" as="geometry"/>
</mxCell>
<mxCell id="3" value="Return result." style="whiteSpace=wrap;html=1;rounded=1;shadow=1;" parent="15" vertex="1">
<mxGeometry x="680" y="159.2" width="132.19" height="80" as="geometry"/>
</mxCell>
<mxCell id="8" value="Yes" style="edgeStyle=none;html=1;entryX=0;entryY=0;entryDx=0;entryDy=0;shadow=1;" parent="15" source="2" target="3" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="4" value="Run input selectors.&lt;br&gt;Are the results of input selectors same as last time?" style="whiteSpace=wrap;html=1;rounded=1;shadow=1;" parent="15" vertex="1">
<mxGeometry x="251.88" y="158.4" width="168.12" height="81.6" as="geometry"/>
</mxCell>
<mxCell id="9" value="No" style="edgeStyle=none;html=1;entryX=1;entryY=0;entryDx=0;entryDy=0;shadow=1;" parent="15" source="2" target="4" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="6" value="Return result." style="whiteSpace=wrap;html=1;rounded=1;shadow=1;" parent="15" vertex="1">
<mxGeometry x="470.7375" y="310" width="135.625" height="44" as="geometry"/>
</mxCell>
<mxCell id="13" value="Yes" style="edgeStyle=none;html=1;entryX=0;entryY=0;entryDx=0;entryDy=0;shadow=1;" parent="15" source="4" target="6" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="7" value="Run result function." style="whiteSpace=wrap;html=1;rounded=1;shadow=1;" parent="15" vertex="1">
<mxGeometry x="59.9975" y="310" width="135.625" height="44" as="geometry"/>
</mxCell>
<mxCell id="14" value="No" style="edgeStyle=none;html=1;entryX=1;entryY=0;entryDx=0;entryDy=0;shadow=1;" parent="15" source="4" target="7" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
Binary file added docs/assets/normal-memoization-function.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/reselect-memoization.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
"format": "prettier --write \"{src,test}/**/*.{js,ts}\" \"docs/**/*.md\"",
"lint": "eslint src test",
"prepack": "yarn build",
"bench": "vitest --run bench",
"bench": "vitest --run bench --mode production",
"test": "node --expose-gc ./node_modules/vitest/dist/cli-wrapper.js run",
"test:cov": "vitest run --coverage",
"type-check": "vitest --run typecheck",
"type-check:trace": "vitest --run typecheck && tsc --noEmit -p typescript_test/tsconfig.json --generateTrace trace && npx @typescript/analyze-trace trace && rimraf trace",
"test:typescript": "tsc --noEmit -p typescript_test/tsconfig.json"
},
"keywords": [
Expand All @@ -54,6 +56,7 @@
"@typescript-eslint/eslint-plugin": "5.1.0",
"@typescript-eslint/eslint-plugin-tslint": "5.1.0",
"@typescript-eslint/parser": "5.1.0",
"@typescript/analyze-trace": "^0.10.1",
"eslint": "^8.0.1",
"eslint-plugin-react": "^7.26.1",
"eslint-plugin-typescript": "0.14.0",
Expand Down
14 changes: 10 additions & 4 deletions src/autotrackMemoize/autotrackMemoize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import {
createCacheKeyComparator,
defaultEqualityCheck
} from '@internal/defaultMemoize'
import type { AnyFunction } from '@internal/types'
import type {
AnyFunction,
DefaultMemoizeFields,
Simplify
} from '@internal/types'
import { createCache } from './autotracking'

/**
Expand Down Expand Up @@ -55,7 +59,7 @@ import { createCache } from './autotracking'
* ```ts
* import { unstable_autotrackMemoize as autotrackMemoize, createSelectorCreator } from 'reselect'
*
* const createSelectorAutotrack = createSelectorCreator(autotrackMemoize)
* const createSelectorAutotrack = createSelectorCreator({ memoize: autotrackMemoize })
*
* const selectTodoIds = createSelectorAutotrack(
* [(state: RootState) => state.todos],
Expand Down Expand Up @@ -93,7 +97,9 @@ export function autotrackMemoize<Func extends AnyFunction>(func: Func) {
return cache.value
}

memoized.clearCache = () => cache.clear()
memoized.clearCache = () => {
return cache.clear()
}

return memoized as Func & { clearCache: () => void }
return memoized as Func & Simplify<DefaultMemoizeFields>
}
Loading
Loading