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

useObserver registry refactor #3598

Merged
merged 6 commits into from
Jan 14, 2023
Merged

useObserver registry refactor #3598

merged 6 commits into from
Jan 14, 2023

Conversation

urugator
Copy link
Collaborator

As discussed here #3590 (comment)

@changeset-bot
Copy link

changeset-bot bot commented Dec 31, 2022

🦋 Changeset detected

Latest commit: b6e7128

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
mobx-react-lite Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@mweststrate mweststrate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, thanks for putting that in a separate PR!

Copy link
Member

@Bnaya Bnaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

less code = It's better :D

throw new Error("This test must run with node >= 14")
}

expect(observerFinalizationRegistry).toBeInstanceOf(globalThis.FinalizationRegistry)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it do if it fails? it's not inside any test

import { observerFinalizationRegistry } from "../src/utils/observerFinalizationRegistry"
import { TimerBasedFinalizationRegistry } from "../src/utils/UniversalFinalizationRegistry"

expect(observerFinalizationRegistry).toBeInstanceOf(TimerBasedFinalizationRegistry)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it do if it fails?

Throws?

it's not inside any test

Does it matter?

It's mainly intented to assert environment (bug in the test), rather than testing that observerFinalizationRegistry resolves to correct type (bug in the actual tested code).
Arguably I could split these into two, assertion to check globalThis for (not) being FinalizationRegistry and then an actual test for observerFinalizationRegistry. However I don't see much value in doing so.

import gc from "expose-gc/function"
import { observerFinalizationRegistry } from "../src/utils/observerFinalizationRegistry"

if (typeof globalThis.FinalizationRegistry !== "function") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change this assertion also to expect to match the other checks?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... But then the error message won't be the same think think

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I did want to preserve the message.

@urugator urugator merged commit 4ef8ff3 into main Jan 14, 2023
@github-actions github-actions bot mentioned this pull request Jan 14, 2023
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.

None yet

4 participants