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

atom.INTERNAL_onInit hook to support sync effects #2801

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

dmaskasky
Copy link
Collaborator

@dmaskasky dmaskasky commented Nov 8, 2024

Summary

  1. Adds a new atom api, atom.INTERNAL_onInit = (store: Store, atomState: AtomState) => void.
    Fires when the atomState is first created in the store for that atom.

  2. Updates store.unstable_derive api to add a new callback param, atomOnInit. This is the interceptor for the atom.unstable_onInit api. Since getAtomState is where atom.unstable_onInit is called, we must add atomOnInit to the getAtomState params. atomOnInit accepts a store arg so that the current store is always passed.

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 23, 2024 3:10am

@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: 8a22c4b
Last updated: Dec 23, 2024 3:10am (UTC)

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

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
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from 3f07f82 to 4ebc654 Compare December 21, 2024 08:27
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from a3f9d5f to 4b35062 Compare December 21, 2024 21:29
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from 4b35062 to 3215a84 Compare December 21, 2024 21:34
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from 3215a84 to 908d767 Compare December 21, 2024 21:35
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from 908d767 to 95e1b4c Compare December 21, 2024 21:43
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from 95e1b4c to 3d43b29 Compare December 21, 2024 21:48
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch 3 times, most recently from 4e1c0fd to 8d13cb8 Compare December 21, 2024 21:52
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from 8d13cb8 to 6bf7d76 Compare December 21, 2024 22:22
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch 2 times, most recently from ada9115 to 445af4f Compare December 21, 2024 22:26
@dmaskasky dmaskasky changed the title atom.unstable_onInit hook to support sync effects atom.INTERNAL_onInit hook to support sync effects Dec 21, 2024
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from 445af4f to c9475c9 Compare December 21, 2024 23:18
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