-
-
Notifications
You must be signed in to change notification settings - Fork 689
refactor: buildingBlocks to storeState #3105
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 GitHub.
|
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: |
|
Playground | Link |
---|---|
React demo | https://livecodes.io?x=id/FLUDNYK4A |
See documentations for usage instructions.
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's hard to see some diffs, but I assume the logic is preserved.
Other than that, it's super clean and I like it. Splendid work!
@arjunvegda Please be aware that this is going to be a breaking change for you. |
This breaks jotai-effect due to the removal of cc @dmaskasky |
Yes, I have to update jotai-effect, and jotai-scope. I'll release this today. |
I just released [email protected], which now supports [email protected]. |
Summary
The current building‑blocks implementation behaves unexpectedly when you try to derive one store from another. Each building‑block function closes over the arguments and default values supplied to the original
buildStore
call, so a derived store reuses those captured values instead of its own, causing unintended behavior.This PR refactors store internals to eliminate parent scope references.
API Changes
Changed
store
prop added to all atom interceptors and building block functionsatomOnInit(atom, store)
->atomOnInit(store, atom)
INTERNAL_buildStore
added argssetAtomStateValueOrPromise
storeGet
storeSet
storeSub
buildingBlocks
added itemssetAtomStateValueOrPromise
storeGet
storeSet
storeSub
type BuildingBlocks
now mutableINTERNAL_getBuildingBlocksRev2
returns typeReadonly<BuildingBlocks>
Added
type INTERNAL_BuildingBlocks
type INTERNAL_StoreHooks
Removed
INTERNAL_SetAtomStateValueOrPromise
Check List
pnpm run fix
for formatting and linting code and docs