forked from reduxjs/reselect
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add documentation regarding new features. - Redo `CodeSandbox` examples to align better with documentation. Solves reduxjs#598. - Fix GitHub workflow badge URL reduxjs#628. - Add instructions for `bun` and `pnpm`. Solves reduxjs#621. - Fix minor type issues regarding `createStructuredSelector`. Solves reduxjs#499. - `argsMemoize` and `argsMemoizeOptions` solve reduxjs#359. - Remove `Redux` legacy patterns including `connect` and `switch` statements from docs. Solves reduxjs#515. - Replace legacy code patterns with modern syntax like `useSelector` and functional components. - Implementation of `argsMemoize` solves reduxjs#376. - Document order of execution in `Reselect`. Solves reduxjs#455. - Add benchmarks to confirm the info inside the documentation. - Add more type tests with `vitest`. - Fix more hover preview issues with types.
- Loading branch information
1 parent
e4fe262
commit f8cdab2
Showing
35 changed files
with
5,027 additions
and
1,013 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.<br>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> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import type { CreateSelectorFunction } from './createSelectorCreator' | ||
import { createSelectorCreator } from './createSelectorCreator' | ||
|
||
import { defaultMemoize } from './defaultMemoize' | ||
import type { | ||
Combiner, | ||
CreateSelectorOptions, | ||
CurriedOutputSelector, | ||
DropFirstParameter, | ||
InterruptRecursion, | ||
SelectorArray, | ||
Simplify, | ||
UnknownMemoizer | ||
} from './types' | ||
|
||
/** | ||
* @WIP | ||
*/ | ||
export interface CreateCurriedSelector< | ||
MemoizeFunction extends UnknownMemoizer = typeof defaultMemoize, | ||
ArgsMemoizeFunction extends UnknownMemoizer = typeof defaultMemoize | ||
> { | ||
/** | ||
* One arg | ||
*/ | ||
<InputSelectors extends SelectorArray, Result>( | ||
...createSelectorArgs: [ | ||
...inputSelectors: InputSelectors, | ||
combiner: Combiner<InputSelectors, Result> | ||
] | ||
): CurriedOutputSelector< | ||
InputSelectors, | ||
Result, | ||
MemoizeFunction, | ||
ArgsMemoizeFunction | ||
> & | ||
InterruptRecursion | ||
|
||
/** | ||
* inline args | ||
*/ | ||
< | ||
InputSelectors extends SelectorArray, | ||
Result, | ||
OverrideMemoizeFunction extends UnknownMemoizer = MemoizeFunction, | ||
OverrideArgsMemoizeFunction extends UnknownMemoizer = ArgsMemoizeFunction | ||
>( | ||
...createSelectorArgs: [ | ||
...inputSelectors: InputSelectors, | ||
combiner: Combiner<InputSelectors, Result>, | ||
createSelectorOptions: Simplify< | ||
CreateSelectorOptions< | ||
MemoizeFunction, | ||
ArgsMemoizeFunction, | ||
OverrideMemoizeFunction, | ||
OverrideArgsMemoizeFunction | ||
> | ||
> | ||
] | ||
): CurriedOutputSelector< | ||
InputSelectors, | ||
Result, | ||
OverrideMemoizeFunction, | ||
OverrideArgsMemoizeFunction | ||
> & | ||
InterruptRecursion | ||
|
||
/** | ||
* array args | ||
*/ | ||
< | ||
InputSelectors extends SelectorArray, | ||
Result, | ||
OverrideMemoizeFunction extends UnknownMemoizer = MemoizeFunction, | ||
OverrideArgsMemoizeFunction extends UnknownMemoizer = ArgsMemoizeFunction | ||
>( | ||
inputSelectors: [...InputSelectors], | ||
combiner: Combiner<InputSelectors, Result>, | ||
createSelectorOptions?: Simplify< | ||
CreateSelectorOptions< | ||
MemoizeFunction, | ||
ArgsMemoizeFunction, | ||
OverrideMemoizeFunction, | ||
OverrideArgsMemoizeFunction | ||
> | ||
> | ||
): CurriedOutputSelector< | ||
InputSelectors, | ||
Result, | ||
OverrideMemoizeFunction, | ||
OverrideArgsMemoizeFunction | ||
> & | ||
InterruptRecursion | ||
} | ||
|
||
/** | ||
* @WIP | ||
*/ | ||
export function createCurriedSelectorCreator< | ||
MemoizeFunction extends UnknownMemoizer = typeof defaultMemoize, | ||
ArgsMemoizeFunction extends UnknownMemoizer = typeof defaultMemoize | ||
>(...createSelectorCreatorArgs: Parameters<typeof createSelectorCreator>) { | ||
const createSelector = createSelectorCreator(...createSelectorCreatorArgs) | ||
|
||
const createCurriedSelector = ( | ||
...createSelectorArgs: Parameters< | ||
CreateSelectorFunction<MemoizeFunction, ArgsMemoizeFunction> | ||
> | ||
) => { | ||
// @ts-ignore | ||
const selector = createSelector.apply(null, createSelectorArgs) | ||
// const selector = createSelector(...createSelectorArgs) | ||
const curriedSelector = selector.argsMemoize( | ||
(...params: DropFirstParameter<typeof selector>) => { | ||
return selector.argsMemoize((state: Parameters<typeof selector>[0]) => { | ||
return selector(state, ...params) | ||
}) | ||
} | ||
) | ||
return Object.assign(curriedSelector, selector) as CurriedOutputSelector | ||
} | ||
return createCurriedSelector as unknown as CreateCurriedSelector< | ||
MemoizeFunction, | ||
ArgsMemoizeFunction | ||
> | ||
} | ||
|
||
/** | ||
* @WIP | ||
*/ | ||
export const createCurriedSelector = | ||
/* #__PURE__ */ createCurriedSelectorCreator(defaultMemoize) |
Oops, something went wrong.