File tree Expand file tree Collapse file tree
packages/command-flow/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,19 +2,33 @@ import { forwardRef, Injectable } from '@angular/core';
22
33@Injectable ( {
44 providedIn : 'root' ,
5- useExisting : forwardRef ( ( ) => AnimationFrameBasedCommandFlowScheduler ) ,
5+ useExisting : forwardRef ( ( ) => SetImmediateCommandFlowScheduler ) ,
66} )
77export abstract class CommandFlowScheduler {
88 abstract next ( fn : ( ) => void ) : void ;
99}
1010
11- @Injectable ( {
12- providedIn : 'root' ,
13- } )
11+ /**
12+ * Implementation of {@link CommandFlowScheduler} that uses
13+ * `setImmediate` to schedule the next execution.
14+ */
15+ @Injectable ( { providedIn : 'root' } )
16+ export class SetImmediateCommandFlowScheduler implements CommandFlowScheduler {
17+ next ( fn : ( ) => void ) : void {
18+ setImmediate ( fn ) ;
19+ }
20+ }
21+
22+ /**
23+ * Implementation of {@link CommandFlowScheduler} that uses
24+ * `requestAnimationFrame` to schedule the next execution.
25+ * Available only in the browser platform.
26+ */
27+ @Injectable ( { providedIn : 'root' } )
1428export class AnimationFrameBasedCommandFlowScheduler
1529 implements CommandFlowScheduler
1630{
1731 next ( fn : ( ) => void ) : void {
18- requestAnimationFrame ( fn ) ;
32+ window . requestAnimationFrame ( fn ) ;
1933 }
2034}
You can’t perform that action at this time.
0 commit comments