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

Closed
wants to merge 4 commits into 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 Jan 1, 2025 3:45am

@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: a1408ad
Last updated: Jan 1, 2025 3:44am (UTC)

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

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 63ce295 to 367d576 Compare December 23, 2024 20:20
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from 367d576 to b11f2a6 Compare December 23, 2024 20:26
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from b11f2a6 to 0a3d32b Compare December 23, 2024 20:32
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from 0a3d32b to 7964122 Compare December 23, 2024 20:36
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from 7964122 to c48b443 Compare December 23, 2024 20:43
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from c48b443 to 0d2e258 Compare December 23, 2024 20:48
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from 0d2e258 to f57d740 Compare December 23, 2024 21:03
@dmaskasky dmaskasky force-pushed the partial-sync-effect-2 branch from f57d740 to f91933a Compare December 23, 2024 21:04
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