@@ -113,7 +113,7 @@ import { serializeAttribute } from './utils/styles';
113
113
import type { ValueOrPromise } from './utils/types' ;
114
114
115
115
// Turn this on to get debug output of what the scheduler is doing.
116
- const DEBUG : boolean = true ;
116
+ const DEBUG : boolean = false ;
117
117
118
118
export const enum ChoreType {
119
119
/// MASKS defining three levels of sorting
@@ -547,6 +547,7 @@ export const createScheduler = (
547
547
if ( isPromise ( returnValue ) ) {
548
548
chore . $promise$ = returnValue . then ( after , ( error ) => after ( undefined , error ) ) ;
549
549
chore . $resolve$ ?.( chore . $promise$ ) ;
550
+ chore . $resolve$ = undefined ;
550
551
} else {
551
552
after ( returnValue ) ;
552
553
}
@@ -644,28 +645,29 @@ export const createScheduler = (
644
645
return ~ bottom ;
645
646
}
646
647
647
- /**
648
- * When a derived signal is update we need to run vnode_diff. However the signal can update
649
- * multiple times during component execution. For this reason it is necessary for us to update the
650
- * schedule work with the latest result of the signal.
651
- */
652
- function choreUpdate ( existing : Chore , newChore : Chore ) : void {
653
- if ( existing . $type$ === ChoreType . NODE_DIFF ) {
654
- existing . $payload$ = newChore . $payload$ ;
655
- }
656
- }
657
-
658
648
function sortedInsert ( sortedArray : Chore [ ] , value : Chore , rootVNode : ElementVNode | null ) : Chore {
659
649
/// We need to ensure that the `queue` is sorted by priority.
660
650
/// 1. Find a place where to insert into.
661
651
const idx = sortedFindIndex ( sortedArray , value , rootVNode ) ;
652
+
662
653
if ( idx < 0 ) {
663
654
/// 2. Insert the chore into the queue.
664
655
sortedArray . splice ( ~ idx , 0 , value ) ;
665
656
return value ;
666
657
}
658
+
667
659
const existing = sortedArray [ idx ] ;
668
- choreUpdate ( existing , value ) ;
660
+ /**
661
+ * When a derived signal is updated we need to run vnode_diff. However the signal can update
662
+ * multiple times during component execution. For this reason it is necessary for us to update
663
+ * the chore with the latest result of the signal.
664
+ */
665
+ if ( existing . $type$ === ChoreType . NODE_DIFF ) {
666
+ existing . $payload$ = value . $payload$ ;
667
+ }
668
+ if ( existing . $executed$ ) {
669
+ existing . $executed$ = false ;
670
+ }
669
671
return existing ;
670
672
}
671
673
} ;
0 commit comments