Skip to content

breaking(internals): pass building blocks directly to internal functions#3280

Open
dmaskasky wants to merge 1 commit intopmndrs:mainfrom
dmaskasky:pr-buildingblocks-first
Open

breaking(internals): pass building blocks directly to internal functions#3280
dmaskasky wants to merge 1 commit intopmndrs:mainfrom
dmaskasky:pr-buildingblocks-first

Conversation

@dmaskasky
Copy link
Copy Markdown
Collaborator

@dmaskasky dmaskasky commented Mar 30, 2026

Summary

Since 2.14.0, the building block architecture relies on passing the store as the first parameter to internal functions. This store was used as a WeakMap key to access building blocks. WeakMap access is not super performant so in certain heavy applications, performance was impacted.

This PR reworks the building block architecture to directly pass buildingBlocks instead of store. This eliminates the WeakMap access per call site.

The breaking change is that BUILDING_BLOCK functions now accept buildingBlocks instead of store as the first parameter.

What was done

  • switch internal function signatures and call sites from store-first to buildingBlocks-first.
  • add store to buildingBlocks (for atomOnInit).
  • update useAtomValue and internals tests to pass buildingBlocks instead of store as the first parameter.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 30, 2026

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

Project Deployment Actions Updated (UTC)
jotai Ready Ready Preview, Comment Mar 30, 2026 6:39am

Request Review

@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci bot commented Mar 30, 2026

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.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 30, 2026

More templates

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

commit: 116e6b4

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 30, 2026

LiveCodes Preview in LiveCodes

Latest commit: 116e6b4
Last updated: Mar 30, 2026 6:39am (UTC)

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

See documentations for usage instructions.

@dmaskasky dmaskasky force-pushed the pr-buildingblocks-first branch from ab0cc38 to f59e61d Compare March 30, 2026 05:34
@dmaskasky dmaskasky changed the title refactor internals to pass building blocks explicitly Breaking: refactor internals to pass building blocks explicitly Mar 30, 2026
@dmaskasky dmaskasky force-pushed the pr-buildingblocks-first branch from f59e61d to 8d2c768 Compare March 30, 2026 06:33
Switch internal building-block function signatures and call sites from store-first to buildingBlocks-first, and update buildStore to wire store APIs from frozen building blocks while keeping weak map storage.

Made-with: Cursor
@dmaskasky dmaskasky force-pushed the pr-buildingblocks-first branch from 8d2c768 to 116e6b4 Compare March 30, 2026 06:39
@dmaskasky dmaskasky changed the title Breaking: refactor internals to pass building blocks explicitly breaking: refactor internals to pass building blocks explicitly Mar 30, 2026
@dmaskasky dmaskasky changed the title breaking: refactor internals to pass building blocks explicitly breaking(internals): refactor internals to pass building blocks explicitly Apr 3, 2026
@dmaskasky dmaskasky changed the title breaking(internals): refactor internals to pass building blocks explicitly breaking(internals): pass building blocks directly to internal functions Apr 3, 2026
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.

1 participant