-
-
Notifications
You must be signed in to change notification settings - Fork 648
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
[WIP] fix(core): expose unstable_resolve instead of unstable_is #2609
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. |
|
Playground | Link |
---|---|
React demo | https://livecodes.io?x=id/CNM5S8ZNH |
See documentations for usage instructions.
6102035
to
896bc81
Compare
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. |
896bc81
to
2480e0b
Compare
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. |
2480e0b
to
18e83e7
Compare
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. |
18e83e7
to
ade00a6
Compare
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. |
ade00a6
to
42244ac
Compare
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. |
42244ac
to
a6b9322
Compare
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. |
a6b9322
to
b8b1b23
Compare
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. |
b8b1b23
to
2de29ae
Compare
008323a
to
3acc1b9
Compare
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. |
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 looks super cool! Thanks for your contribution.
Now, this PR fixes both store and store2, I think it can be released as a patch.
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. |
89fe100
to
7e259b9
Compare
[DO_NOT_MERGE] I am still trying to understand whether this change will satisfy the needs of jotai-scope. I might go in a slightly different direction. |
Co-authored-by: David Maskasky <dmaskasky@otter.ai>
* add failing tests for unstable_resolve * Apply suggestions from code review * Apply suggestions from code review * Update tests/vanilla/store.test.tsx * hack types --------- Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com> Co-authored-by: daishi <daishi@axlight.com>
7e259b9
to
9ec28ce
Compare
* experimental(core): expose unstable_derive instead of unstable_is * chore: remove empty line * chore types * follow resolveAtom in #2609 * store test from #2609 * adjust store.test.tsx for unstable_derive * limit atom state map type * add test with atom state map * update test using unstable_derive * drop resolveAtom, add derive atom test * simplify unstable_derive * wip: this works but i do not like it * separate atomstate and atomcontext * for old ts * fix * fix 2 * simplify a bit with dev breaking changes * revert to bd9c6c0, except for new test * refactor (skipping the new test for now) * refactor 2 * revert those refactors :-p * wip: hm, how is bundle size? * fix tests * add test for unstable_derive (#2665) * add a failing test * wip: failed attempt * split unstable_derive test * wip: failed attempt 2 * revert failing tests * empty commit * restore unstable_is of now (we will remove it in the later version.) --------- Co-authored-by: David Maskasky <dmaskasky@gmail.com> Co-authored-by: David Maskasky <dmaskasky@otter.ai>
Related Issues or Discussions
Replaces PR: #2569
Context
jotai-scope implementation can be made simpler if the store exposed the ability to customize which atom config to reference based on another atom config.
Summary
unstable_resolve
is a new store method. This method customizes how atoms are resolved by their atom config (e.g. using an atom as a key to look up another atom). By default the resolve behavior isatom => atom
.ResolveAtom Invocation Sites
The following functions convert their atom arg to a resolved atom. Since these six functions cover the store interface, it is not necessary to call resolveAtom elsewhere.
readAtom
writeAtom
subscribeAtom
readAtomState -> getter
writeAtomState -> getter
writeAtomState -> setter
Note: store dev methods do not call resolveAtom. The caller of these dev methods is expected to handle atom resolution.
Example
TODO
Check List
pnpm run prettier
for formatting code and docs