-
-
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
feat(core): add atom hooks for atom mount, unmount and improve dev store #2895
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: |
Preview in LiveCodesLatest commit: fd8dcb2
See documentations for usage instructions. |
15151a4
to
81b3e77
Compare
81b3e77
to
a7ffc4e
Compare
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.
Looks good to me. Thanks for the suggestion. This is much cleaner.
I'll merge this when we are ready to release another patch.
/ecosystem-ci run |
Ecosystem CI Output
|
@@ -100,6 +100,8 @@ type AtomState<Value = AnyValue> = { | |||
n: number | |||
/** Object to store mounted state of the atom. */ | |||
m?: Mounted // only available if the atom is mounted | |||
/** Listener to notify when the atom is mounted or unmounted. */ | |||
h?: () => void |
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.
If you want to change this with another character, we can reconsider.
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.
How about
h?: (action: 'm' | 'u', batch: Batch) => void
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.
'm' | 'u'
doesn't look too bad even though it increases the bundle size. I'm hesitant to expose batch here, and looking for an alternative.
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.
We may change 'h'
in the future, but as this is considered internal, it's fine.
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.
I'm hesitant to expose batch here, and looking for an alternative.
Its pretty central to syncBatch scheduling.
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.
I'm working on it, and not sure if it's successful, but I feel like reverting this PR... Will see.
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.
Will see.
It failed.
aec1ca4
to
3223576
Compare
@@ -100,6 +100,8 @@ type AtomState<Value = AnyValue> = { | |||
n: number | |||
/** Object to store mounted state of the atom. */ | |||
m?: Mounted // only available if the atom is mounted | |||
/** Listener to notify when the atom is mounted or unmounted. */ | |||
h?: () => void |
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.
We may change 'h'
in the future, but as this is considered internal, it's fine.
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.
Much cleaner without Proxy hack.
Summary
Adds hooks
u
andh
to atomState that are called in-place immediately after atom mount changes or the atomState has updated.Check List
pnpm run prettier
for formatting code and docs