Skip to content
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

[Not For Merge] Ideating sync callback mechanism after flushPending #2801

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

dmaskasky
Copy link
Collaborator

@dmaskasky dmaskasky commented Nov 8, 2024

Summary

  1. adds two new apis
  • atom.unstable_onInit = (store: Store) => void
  • store.unstable_onChange = () => void

onChange lifecycle hook

This event triggers for atoms that have been computed and after all atoms have been computed.

Supplemental

  • adds initial test for synchronous effect

Check List

  • pnpm run prettier for formatting code and docs

Copy link

vercel bot commented Nov 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
jotai ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 18, 2024 5:28am

@dmaskasky dmaskasky marked this pull request as draft November 8, 2024 02:51
@dmaskasky dmaskasky changed the title propose: synchronous effects [Not For Merge]: synchronous effects experiment Nov 8, 2024
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from db5bd2b to 0b54ff6 Compare November 8, 2024 02:52
Copy link

codesandbox-ci bot commented Nov 8, 2024

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.

Copy link

github-actions bot commented Nov 8, 2024

LiveCodes Preview in LiveCodes

Latest commit: 85c947a
Last updated: Dec 18, 2024 5:28am (UTC)

Playground Link
React demo https://livecodes.io?x=id/GKF3BW59F

See documentations for usage instructions.

@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from 0b54ff6 to 9e458ba Compare November 8, 2024 02:59
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from 9e458ba to 902aeec Compare November 8, 2024 03:20
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from 902aeec to 687b1ec Compare November 8, 2024 03:23
@dmaskasky dmaskasky changed the title [Not For Merge]: synchronous effects experiment [WIP]: atom.onAfterFlushPending Nov 8, 2024
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from 7d84875 to 93e4fe0 Compare November 8, 2024 21:07
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from 93e4fe0 to 3c13dd4 Compare November 8, 2024 21:34
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from 585d208 to e50b53a Compare November 8, 2024 23:45
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from e50b53a to eff1be8 Compare November 8, 2024 23:47
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from eff1be8 to 97ce448 Compare November 8, 2024 23:50
@dmaskasky dmaskasky marked this pull request as ready for review November 8, 2024 23:52
@dmaskasky dmaskasky changed the title [WIP]: atom.onAfterFlushPending atom.onAfterFlushPending Nov 8, 2024
src/vanilla/store.ts Outdated Show resolved Hide resolved
Copy link
Member

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preliminary task.

@@ -513,11 +544,14 @@ const buildStore = (getAtomState: StoreArgs[0]): Store => {
} else {
r = writeAtomState(pending, a, aState, ...args) as R
}
flushPending(pending)
flushPending(pending, !isSync)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#2804 Let's focus on it separately. If you can help it, I appreciate it. Otherwise, I'll tackle when I have time.

Copy link

pkg-pr-new bot commented Dec 18, 2024

Open in Stackblitz

More templates

npm i https://pkg.pr.new/jotai@2801

commit: 85c947a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants