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

feat(utils): atomWithLazy for lazily initialized primitive atoms. #2465

Merged
merged 10 commits into from
Apr 4, 2024

Conversation

iwoplaza
Copy link
Contributor

Related Issues or Discussions

Realizes an idea proposed in this issue: #2458

Check List

  • yarn run prettier for formatting code and docs

Copy link

vercel bot commented Mar 25, 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 Apr 4, 2024 2:15am

Copy link

codesandbox-ci bot commented Mar 25, 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 Mar 25, 2024

LiveCodes Preview in LiveCodes

Latest commit: 72f8320
Last updated: Apr 4, 2024 2:14am (UTC)

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

See documentations for usage instructions.

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.

Nice. It looks great.

Would you like to add docs too? (If you are busy, a follow-up PR is also fine.)

@dai-shi dai-shi added this to the v2.7.2 milestone Mar 25, 2024
@iwoplaza
Copy link
Contributor Author

Writing a doc for it right now

@dai-shi dai-shi modified the milestones: v2.7.2, v2.8.0 Mar 29, 2024
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.

It looks great. Thanks for your contribution!

@dai-shi dai-shi merged commit c81246e into pmndrs:main Apr 4, 2024
34 checks passed
@dai-shi dai-shi mentioned this pull request Apr 6, 2024
return {
...atom(undefined as unknown as Value),
get init() {
return makeInitial()
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this function be called only once crossing the store?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it should.

Copy link
Member

Choose a reason for hiding this comment

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

should this function be called only once crossing the store?

No, it should call once for each store.
#2458 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I thought that is what they meant. Once per each store is right.

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.

Idea: lazy initialization for primitive atoms
3 participants