Skip to content

Run input selectors twice, to check stability.#612

Merged
markerikson merged 12 commits into
masterfrom
stability-check
May 14, 2023
Merged

Run input selectors twice, to check stability.#612
markerikson merged 12 commits into
masterfrom
stability-check

Conversation

@EskiMojo14
Copy link
Copy Markdown
Contributor

@EskiMojo14 EskiMojo14 commented May 13, 2023

fixes #611

@codesandbox-ci
Copy link
Copy Markdown

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

Comment thread src/index.ts Outdated
Comment thread src/index.ts Outdated
@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
Copy Markdown
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?

Comment thread src/index.ts Outdated
Comment thread src/index.ts
)

// @ts-ignore
const makeAnObject: (...args: unknown[]) => object = memoize(
Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread src/index.ts
makeAnObject.apply(null, params) ===
makeAnObject.apply(null, paramsCopy)
if (!equal) {
// do we want to log more information about the selector?
Copy link
Copy Markdown
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
Copy Markdown
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 🙂

Comment thread test/inputStabilityCheck.spec.ts
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