-
-
Notifications
You must be signed in to change notification settings - Fork 635
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
New store implementation as store2.ts
#2463
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. |
Size Change: +18.3 kB (+25%) 🚨 Total Size: 90.6 kB
ℹ️ View Unchanged
|
Preview in LiveCodesLatest commit: 72329c3
See documentations for usage instructions. |
Tagging those who might be interested: @arjunvegda @dmaskasky @backbone87 @iwoplaza |
I will merge this for |
Co-authored-by: Iwo Plaza <iwoplaza@gmail.com>
*/ | ||
readonly d: Map<AnyAtom, { readonly v: AnyValue } | { readonly e: AnyError }> | ||
/** Set of atoms that depends on the atom. */ | ||
readonly t: Set<AnyAtom> |
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.
As this holds a strong reference, it may cause memory leaks.
We should create a failing test case and fix it. (Probably by moving it to Mounted
, or possibly with WeakRef but unlikely.)
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.
The current store implementation is based on the assumption I made in Jotai v1. Since then, it has changed and v2 design is slightly different. Technically speaking, in v1, we tried to support state branching (or state versioning) which we gave up in v2. So, the store implementation could be a little simpler. This PR introduces a new implementation with mutable atom state. Currently, we have a new
store2.ts
file and run tests to bothstore.ts
andstore2.ts
. We hope to replacestore.ts
withstore2.ts
eventually. This is not the end, but the start. We might be able to simplify the new implementation and add some new capabilities. But, for now, the migration is important especially with/for jotai-devtools. It takes time.