-
-
Notifications
You must be signed in to change notification settings - Fork 638
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
refactor: eliminate batch #2925
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: -192 B (-0.21%) Total Size: 91.9 kB
ℹ️ View Unchanged
|
Preview in LiveCodesLatest commit: c601bd9
See documentations for usage instructions. |
Wait, I might notice some issues. I will continue working on it. Until then, this isn't ready. |
Beautiful PR. This is the next evolution of the store code. I had a feeling the store was getting quite bloated with all the batch logic, I'm glad you figured this out. |
Is my understanding of the semantic difference between these correct?
Could we replace |
Co-authored-by: David Maskasky <[email protected]>
Maybe not. |
…to refactor/eliminate-batch
/ecosystem-ci run |
Ecosystem CI Output
|
/ecosystem-ci run |
Ecosystem CI Output
|
Co-authored-by: David Maskasky <[email protected]>
Let me confirm that this still fails with jotai-effect. |
/ecosystem-ci run |
Ecosystem CI Output
|
Final status:
|
Background
Batch (formerly Pending) was introduced a long time ago. The major purpose was to provide an async context (Like AsyncLocalStorage) to hold state concurrently. It was really necessary at some point (before v1?), but after v2 or so, the purpose has been more for organizing store.ts code so that atoms are isolated. Like the store doesn't know about all atoms. However as we introduced #2827 and other PRs, the store now coordinates atoms as the single source of truth, and we had to tweak Batch. #2905 went further. I expected that I could change it towards the designed shape, but #2919 and #2918 didn't work.
Moving forward
If we use the store as the single source of truth, I don't think we need batch. Interestingly, I just noticed that
batch
isn't used in readAtomState at all. We are just passing it recursively without consuming it. I don't remember when this has changed. This PR is only to eliminate batch, but I have a big picture in mind which is close to #2911, but I'll explore a bit more. The end goal is probably providing a bunch of hooks, so that the ecosystem libraries can do anything on their own risks. There should be more room to minimize the store code, but that will be tackled afterwards.