File tree 1 file changed +15
-2
lines changed
packages/command-flow/src
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 1
- import { forwardRef , Injectable } from '@angular/core' ;
1
+ import {
2
+ ExperimentalPendingTasks ,
3
+ forwardRef ,
4
+ inject ,
5
+ Injectable ,
6
+ } from '@angular/core' ;
2
7
3
8
@Injectable ( {
4
9
providedIn : 'root' ,
@@ -11,18 +16,26 @@ export abstract class CommandFlowScheduler {
11
16
/**
12
17
* Implementation of {@link CommandFlowScheduler} that uses
13
18
* `setImmediate` to schedule the next execution.
19
+ * The scheduled function is added to {@link PendingTask} for SSR support.
14
20
*/
15
21
@Injectable ( { providedIn : 'root' } )
16
22
export class SetTimeoutCommandFlowScheduler implements CommandFlowScheduler {
23
+ #tasks = inject ( ExperimentalPendingTasks ) ;
24
+
17
25
next ( fn : ( ) => void ) : void {
18
- setTimeout ( fn ) ;
26
+ const done = this . #tasks. add ( ) ;
27
+ setTimeout ( ( ) => {
28
+ fn ( ) ;
29
+ done ( ) ;
30
+ } ) ;
19
31
}
20
32
}
21
33
22
34
/**
23
35
* Implementation of {@link CommandFlowScheduler} that uses
24
36
* `requestAnimationFrame` to schedule the next execution.
25
37
* Available only in the browser platform.
38
+ * @deprecated prefer {@link SetTimeoutCommandFlowScheduler} for better compatibility.
26
39
*/
27
40
@Injectable ( { providedIn : 'root' } )
28
41
export class AnimationFrameCommandFlowScheduler
You can’t perform that action at this time.
0 commit comments