-
-
Notifications
You must be signed in to change notification settings - Fork 634
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
[idea] add pending to store.unstable_derive
#2854
base: main
Are you sure you want to change the base?
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. |
Preview in LiveCodesLatest commit: 2fcca60
See documentations for usage instructions. |
src/vanilla/store.ts
Outdated
atom: WritableAtom<Value, Args, Result>, | ||
setAtom: (...args: Args) => Result, | ||
) => OnUnmount | void, | ||
createPending: (prevPending?: Pending | undefined) => Pending, |
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.
prevPending is the in-context upstream pending. For instance, unsubscribe's invocation of createPending receives subscribe's pending.
store.unstable_derive
store.unstable_derive
This is pretty close to our rejected idea (ref #2741), so I have a big hesitation. In any case, my plan for this is after we finalize "sync effect". So, converting to draft for now. (already converted. 😄 ) |
Yeah, I was thinking that too. I think I prefer this pattern over some sort of hooks pattern for low-level store api. |
The big difference in my mind is that pending gives a place for extra details about the transaction to be processed. The difficulty we had with the earlier idea with passing Say we had Now with flushPending, we are free to implement our own linked list or whatever. This might be something to consider if the need ever arises. |
d8037ec
to
eba5be0
Compare
Summary
Improves capability of unstable_derive store api. Pending is a good candidate to represent a transaction primitive. These changes make it possible to have fine-grained control over the atom lifecycle.
Details
Check List
pnpm run prettier
for formatting code and docs