-
-
Notifications
You must be signed in to change notification settings - Fork 689
[Not For Merge] wip: internals rev2 #3104
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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. |
commit: |
Size Change: +1.35 kB (+1.37%) Total Size: 99.6 kB
ℹ️ View Unchanged
|
|
Playground | Link |
---|---|
React demo | https://livecodes.io?x=id/FZRB764RX |
See documentations for usage instructions.
if (import.meta.env?.MODE !== 'production' && !atom) { | ||
throw new Error('Atom is undefined or null') | ||
} | ||
let atomState = atomStateMap.get(atom) |
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.
This might be the same issue. ensureAtomState
closes over the storeState destructure which causes it to reuse those captured values. If we want swappable pieces, my guess is that we would have to destructure within ensureAtomState
and other building block functions.
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.
I think a good test would be to do,
const asm0 = { get: vi.fn(() => ({ d: new Set() })), has: () => true }
const buildingBlocks0 = asm0
const store0 = INTERNAL_buildStore(...buildingBlocks0)
const [...buildingBlocks1] = INTERNAL_getBuildingBlocks(store0)
const asm1 = { get: vi.fn(() => ({ d: new Set() })), has: () => true }
buildingBlocks1[0] = asm1
const store1 = INTERNAL_buildStore(...buildingBlocks1)
const a = atom(0)
store1.get(a)
expect(asm1.get).toBeCalled()
expect(asm0.get).not.toBeCalled()
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.
With this rev2, my expectation is to call createBuildingBlocks again for the second store. You could argue that building blocks of the first store has changed, but we can't assure they don't use closure state anyways. We need some assumptions.
Closing in favor of #3105. |
To expand our idea.