-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: synchronous atomEffect #53
base: main
Are you sure you want to change the base?
Conversation
package.json
Outdated
@@ -75,7 +76,7 @@ | |||
"html-webpack-plugin": "^5.5.3", | |||
"jest": "^29.7.0", | |||
"jest-environment-jsdom": "^29.7.0", | |||
"jotai": "2.10.3", | |||
"jotai": "https://pkg.csb.dev/pmndrs/jotai/commit/3b435d79/jotai", |
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.
FIXME: replace with official version once available.
0d23697
to
05e030f
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. |
e8c8dd3
to
2101048
Compare
Is this published anywhere? I think I ran into this 'problem' in the following situation:
I could be wrong and my issue may have had nothing to do with this. But, either way, I'd be interested to find out if I could remove the slightly strange logic I wrote to make things work. |
Could you make a simple reproduction of this logic in a codesandbox? I'm wrapping this PR up quickly and can test the new build against what you have there. I think what you have sounds reasonable. Currently, atomEffects have a microtask delay from when their atom dependency changed (e.g the atom was set), to when the effect runs. This PR removes that delay. But the effect's get and set are already both synchronous. I think you need the deferred promise because you are waiting for next signal, which is reasonable. So for next steps, let me see what you currently have in a codesandbox. |
@dmaskasky Something like this? https://codesandbox.io/p/sandbox/spring-glade-hvrczc?file=%2Fsrc%2FApp.js%3A31%2C1 Btw, is there any difference between wrapping an atom with |
Ah, I see what's going on. Let's move this to a GH discussion. #54 |
51b4913
to
e774763
Compare
9fa56d1
to
ab6d12a
Compare
9209b91
to
d9cebeb
Compare
af2e616
to
a39282a
Compare
Related Discussion
#52
Summary
Refactor atomEffect to be synchronous. Synchronous atom effects run in the current task before store subscribers (such as
store.sub
andatom.onMount
.TODO