File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,7 @@ type Store = {
156156 ...args : Args
157157 ) => Result
158158 sub : ( atom : AnyAtom , listener : ( ) => void ) => ( ) => void
159+ [ BUILDING_BLOCKS_KEY ] : Readonly < BuildingBlocks >
159160}
160161
161162type BuildingBlocks = [
@@ -1002,10 +1003,10 @@ const BUILDING_BLOCK_abortPromise: AbortPromise = (store, promise) => {
10021003 abortHandlers ?. forEach ( ( fn ) => fn ( ) )
10031004}
10041005
1005- const buildingBlockMap = new WeakMap < Store , Readonly < BuildingBlocks > > ( )
1006+ const BUILDING_BLOCKS_KEY : unique symbol = Symbol ( 'buildingBlocks' )
10061007
10071008const getInternalBuildingBlocks = ( store : Store ) : Readonly < BuildingBlocks > => {
1008- const buildingBlocks = buildingBlockMap . get ( store ) !
1009+ const buildingBlocks = store [ BUILDING_BLOCKS_KEY ]
10091010 if ( import . meta. env ?. MODE !== 'production' && ! buildingBlocks ) {
10101011 throw new Error (
10111012 'Store must be created by buildStore to read its building blocks' ,
@@ -1077,7 +1078,7 @@ function buildStore(...buildArgs: Partial<BuildingBlocks>): Store {
10771078 [ 0 ] ,
10781079 ] satisfies BuildingBlocks
10791080 ) . map ( ( fn , i ) => buildArgs [ i ] || fn ) as BuildingBlocks
1080- buildingBlockMap . set ( store , Object . freeze ( buildingBlocks ) )
1081+ store [ BUILDING_BLOCKS_KEY ] = Object . freeze ( buildingBlocks )
10811082 return store
10821083}
10831084
You can’t perform that action at this time.
0 commit comments