Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upUse 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) |
This comment has been minimized.
This comment has been minimized.
montemishkin
Jul 27, 2018
Author
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-io
commented
Jul 27, 2018
•
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.
|
PavelDemyanenko
commented
May 16, 2019
|
Any news on this request? Looks good to me |
Zhuvikin
commented
May 16, 2019
|
Faced the same issue. Is it planned to be merged? |
ms88privat
commented
Dec 10, 2019
•
|
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 |
yoavniran
commented
Dec 22, 2019
|
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 |
oasisvali
commented
Feb 12, 2020
•
|
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.
|

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

montemishkin commentedJul 20, 2018
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
memoizeimplementation, but does not pass the caller'smemoizeOptions. This PR changes it to pass thememoizeOptions.