-
Notifications
You must be signed in to change notification settings - Fork 672
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
Use provided memoize options in outer memoize call #359
Conversation
There are two memoize calls in `createSelectorCreator`. One is to memoize the so called `resultFunc`. The other memoize allows us to skip out early if the resulting selector is called with the exact same arguments. Currently, this second memoize uses the caller's provided `memoize` implementation, but does not pass the caller's `memoizeOptions`. This PR changes it to pass the `memoizeOptions`.
assert.equal(selector({ a: 2 }), 1) | ||
assert.equal(selector.recomputations(), 1) | ||
// again returns `1` since `typeof state` is still "object" | ||
assert.equal(selector({ a: 'A' }), 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its worth highlighting that this is a subtle change in behavior and could break dependent codebases. So bumping a version number seems to be in order
Codecov Report
@@ Coverage Diff @@
## master #359 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 1 1
Lines 15 15
=====================================
Hits 15 15
Continue to review full report at Codecov.
|
Any news on this request? Looks good to me |
Faced the same issue. Is it planned to be merged? |
I just investigated a related topic. I really think we should pass two memoize and two options to this selectorCreator, so everybody can decide what they want exactly. They should not depend on each other whatsoever. I was not happy when #297 was introduced. This forced me to do an expensive |
facing the same issue exactly. passing memoizeOptions to the sub selectors makes a lot of sense, or at least being able to control this with a flag so it can be opt it |
For those looking for a workaround in the meantime, I've found using the following pattern to be helpful:
A nice side-effect of using this is that it unlocks the ability to use different memoization strategies for the overall selector arguments vs output function arguments. e.g.
|
- 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.
v5 allows separate |
There are two memoize calls in
createSelectorCreator
. One is to memoize the so calledresultFunc
. The other memoize allows us to skip out early if the resulting selector is called with the exact same arguments.Currently, this second memoize uses the caller's provided
memoize
implementation, but does not pass the caller'smemoizeOptions
. This PR changes it to pass thememoizeOptions
.