File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed
packages/svelte/src/internal/client/reactivity Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -703,18 +703,18 @@ export function schedule_effect(signal) {
703703 queued_root_effects . push ( effect ) ;
704704}
705705
706- /** @type {Source<number> } */
707- let version ;
708-
709- let eager_flushing = false ;
706+ /** @type {Source<number>[] | null } */
707+ let eager_flushing = null ;
710708
711709function eager_flush ( ) {
712710 try {
713711 flushSync ( ( ) => {
714- update ( version ) ;
712+ /** @type {Source<number>[] } */ ( eager_flushing ) . forEach ( ( version ) => {
713+ update ( version ) ;
714+ } ) ;
715715 } ) ;
716716 } finally {
717- eager_flushing = false ;
717+ eager_flushing = null ;
718718 }
719719}
720720
@@ -725,11 +725,12 @@ function eager_flush() {
725725 * @returns {T }
726726 */
727727export function eager ( fn ) {
728- get ( ( version ??= source ( 0 ) ) ) ;
729-
728+ var version = source ( 0 ) ;
730729 var initial = true ;
731730 var value = /** @type {T } */ ( undefined ) ;
732731
732+ get ( version ) ;
733+
733734 inspect_effect ( ( ) => {
734735 if ( initial ) {
735736 // the first time this runs, we create an inspect effect
@@ -750,9 +751,10 @@ export function eager(fn) {
750751 // `version` update. since this will recreate the effect,
751752 // we don't need to evaluate the expression here
752753 if ( ! eager_flushing ) {
753- eager_flushing = true ;
754+ eager_flushing = [ ] ;
754755 queue_micro_task ( eager_flush ) ;
755756 }
757+ eager_flushing . push ( version ) ;
756758 } ) ;
757759
758760 initial = false ;
You can’t perform that action at this time.
0 commit comments