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

Run input selectors twice, to check stability. #612

Merged
merged 12 commits into from May 14, 2023
Merged

Conversation

EskiMojo14
Copy link
Contributor

@EskiMojo14 EskiMojo14 commented May 13, 2023

fixes #611

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 13, 2023

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:

Sandbox Source
Vanilla Configuration
Vanilla Typescript Configuration

src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
@EskiMojo14 EskiMojo14 changed the title Begin investigating running input selectors twice, to check stability. Run input selectors twice, to check stability. May 14, 2023
Copy link
Contributor

@markerikson markerikson left a 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?

src/index.ts Outdated Show resolved Hide resolved
@@ -120,6 +127,15 @@ export function createSelectorCreator<
...finalMemoizeOptions
)

// @ts-ignore
const makeAnObject: (...args: unknown[]) => object = memoize(
Copy link
Contributor

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?

Copy link
Contributor Author

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?
Copy link
Contributor

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?

Copy link
Contributor Author

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 🙂

test/inputStabilityCheck.spec.ts Show resolved Hide resolved
@markerikson markerikson marked this pull request as ready for review May 14, 2023 21:48
@markerikson markerikson merged commit 1a85288 into master May 14, 2023
18 checks passed
@markerikson markerikson deleted the stability-check branch May 14, 2023 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run selectors twice in development to warn for memoization failures
2 participants