@@ -211,10 +211,7 @@ const registerBatchAtom = (
211211 }
212212}
213213
214- const flushBatch = (
215- batch : Batch ,
216- recomputeDependents : ( batch : Batch ) => void ,
217- ) => {
214+ const flushBatch = ( batch : Batch ) => {
218215 let error : AnyError
219216 let hasError = false
220217 const call = ( fn : ( batch : Batch ) => void ) => {
@@ -228,7 +225,6 @@ const flushBatch = (
228225 }
229226 }
230227 while ( batch . C . size || batch . some ( ( channel ) => channel . size ) ) {
231- recomputeDependents ( batch )
232228 batch . C . clear ( )
233229 for ( const channel of batch ) {
234230 channel . forEach ( call )
@@ -382,7 +378,7 @@ const buildStore = (...storeArgs: StoreArgs): Store => {
382378 const batch = createBatch ( )
383379 addDependency ( atom , atomState , a , aState )
384380 mountDependencies ( batch , atom , atomState )
385- recomputeAndFlushBatch ( batch )
381+ flushBatch ( batch )
386382 }
387383 }
388384 }
@@ -424,7 +420,7 @@ const buildStore = (...storeArgs: StoreArgs): Store => {
424420 if ( atomState . m ) {
425421 const batch = createBatch ( )
426422 mountDependencies ( batch , atom , atomState )
427- recomputeAndFlushBatch ( batch )
423+ flushBatch ( batch )
428424 }
429425 }
430426 valueOrPromise . then ( complete , complete )
@@ -543,9 +539,6 @@ const buildStore = (...storeArgs: StoreArgs): Store => {
543539 }
544540 }
545541
546- const recomputeAndFlushBatch = ( batch : Batch ) =>
547- flushBatch ( batch , recomputeDependents )
548-
549542 const writeAtomState = < Value , Args extends unknown [ ] , Result > (
550543 batch : Batch ,
551544 atom : WritableAtom < Value , Args , Result > ,
@@ -580,7 +573,7 @@ const buildStore = (...storeArgs: StoreArgs): Store => {
580573 }
581574 } finally {
582575 if ( ! isSync ) {
583- recomputeAndFlushBatch ( batch )
576+ flushBatch ( batch )
584577 }
585578 }
586579 }
@@ -599,7 +592,7 @@ const buildStore = (...storeArgs: StoreArgs): Store => {
599592 try {
600593 return writeAtomState ( batch , atom , ...args )
601594 } finally {
602- recomputeAndFlushBatch ( batch )
595+ flushBatch ( batch )
603596 }
604597 }
605598
@@ -656,7 +649,7 @@ const buildStore = (...storeArgs: StoreArgs): Store => {
656649 return writeAtomState ( batch , atom , ...args )
657650 } finally {
658651 if ( ! isSync ) {
659- recomputeAndFlushBatch ( batch )
652+ flushBatch ( batch )
660653 }
661654 }
662655 }
@@ -713,12 +706,12 @@ const buildStore = (...storeArgs: StoreArgs): Store => {
713706 const mounted = mountAtom ( batch , atom , atomState )
714707 const listeners = mounted . l
715708 listeners . add ( listener )
716- recomputeAndFlushBatch ( batch )
709+ flushBatch ( batch )
717710 return ( ) => {
718711 listeners . delete ( listener )
719712 const batch = createBatch ( )
720713 unmountAtom ( batch , atom , atomState )
721- recomputeAndFlushBatch ( batch )
714+ flushBatch ( batch )
722715 }
723716 }
724717
0 commit comments