-
Notifications
You must be signed in to change notification settings - Fork 670
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
Run input selectors twice, to check stability. #612
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit afc8bd3:
|
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.
Looks good overall. Can you make these couple tweaks?
@@ -120,6 +127,15 @@ export function createSelectorCreator< | |||
...finalMemoizeOptions | |||
) | |||
|
|||
// @ts-ignore | |||
const makeAnObject: (...args: unknown[]) => object = memoize( |
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.
✋ Should this be moved inside the NODE_ENV
check?
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.
it could, but i think that would be worse for performance? this creates one function when the selector is created, moving it inside would make a new function every time the check runs
makeAnObject.apply(null, params) === | ||
makeAnObject.apply(null, paramsCopy) | ||
if (!equal) { | ||
// do we want to log more information about the selector? |
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.
💬 What happens if we reference selector.name
here? Does it end up as "selector"
, or whatever we assigned it to?
Scratch that, it comes back as "memoized"
, because defaultMemoize.ts
has function memoized()
.
Mmm... We could at least log out the original inputs and both sets of extracted values?
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.
added
{
arguments,
firstInputs: params,
secondInputs: paramsCopy
}
open to better names 🙂
fixes #611