-
-
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
alternate implementation for #2801 #2888
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
I would like to propose a few changes here to guarantee that effect runs after recomputeDependent and before listeners and mount hooks. I am not 100% with any of this yet. We may also need new tests specifically to support the behavior change to synchronous operation.
function getAtomState(store: Store, atom: AnyAtom): AtomState {
let atomState: AtomState
try {
store.unstable_derive((getAtomState) => {
atomState = getAtomState(atom)!
return null as any
})
} catch {
// expect error
}
return atomState!
}
const originalMl = ref.atomState.ml
ref.atomState.ml = () => {
if (ref.atomState.m) {
// handle on mount
} else {
// handle on unmount
}
originalMl?.()
}
const scheduleListeners = () => {
for (const [listener, priority] of atomState.l) {
addBatchFunc(batch, priority, listener)
}
}
// note the extra high priority function
addBatchFunc(batch, 'H', () => addBatchFunc(batch, 'H', scheduleListeners))
|
Thanks for your review!
|
We'll work on a new PR. |
alternate implementation for #2801
Goals:
Remaining:
FIXME
comments in effect.test.ts