Skip to content

Conversation

@dmaskasky
Copy link
Collaborator

Summary

Fires after recomputeInvalidatedAtoms is called.

Check List

  • pnpm run fix for formatting and linting code and docs

@vercel
Copy link

vercel bot commented Dec 14, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
jotai Ready Ready Preview, Comment Dec 14, 2025 6:40am

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 14, 2025

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.

@dmaskasky
Copy link
Collaborator Author

dmaskasky commented Dec 14, 2025

Is there a better letter name than g?

@github-actions
Copy link

github-actions bot commented Dec 14, 2025

LiveCodes Preview in LiveCodes

Latest commit: c7233f2
Last updated: Dec 14, 2025 6:39am (UTC)

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

See documentations for usage instructions.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 14, 2025

More templates

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

commit: c7233f2

}
invalidatedAtoms.delete(a)
}
storeHooks.g?.()
Copy link
Member

Choose a reason for hiding this comment

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

Is this enough for your case? I was thinking about adding hook in the above if loop for each recomputed atom.

This looks pretty similar to storeHooks.f. Doesn't it work for your case? If not, I would like to understand what is the difference.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was thinking I would use storeHooks.c for inside the loop and storeHooks.g once the loop has finished.

I agree storeHooks.g is too similar to storeHooks.f. My concern with using storeHook.f was more about semantics. I really don't want to add more hooks if it can be avoided, but I worry that it might just be coincidence that flushCallbacks always runs after recomputeInvalidatedAtoms.

Also, it might race things that run in storeHooks.f, such as atomEffect, but I have a workaround in mind for atomEffect of ot comes to it.

What do you suggest?

Copy link
Member

Choose a reason for hiding this comment

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

My thought is yes, .f and .g are too similar, and not good for the future.
If you care about the semantics, my suggestion is to drop both the current .f and this new .g and create a new hook that works both for -scope and -effect. I'd expect the new one to have better semantics, and probably it will be moved out of flushCallback internal loop.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, I think I'll close the PR for now. I'll try to make it work with storeHooks.f. Keeping storeHooks.f inside the flushCallbacks loop is intentional to process the atoms set by effect.

Copy link
Member

Choose a reason for hiding this comment

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

Keeping storeHooks.f inside the flushCallbacks loop is intentional to process the atoms set by effect.

I see.

@dai-shi dai-shi marked this pull request as draft December 25, 2025 07:39
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