@@ -17,6 +17,8 @@ import {
17
17
} from 'rxjs' ;
18
18
import { observeOn , subscribeOn , tap } from 'rxjs/operators' ;
19
19
20
+ declare const Zone : { current : unknown } | undefined ;
21
+
20
22
/**
21
23
* Schedules tasks so that they are invoked inside the Zone that is passed in the constructor.
22
24
*/
@@ -33,9 +35,13 @@ export class ɵZoneScheduler implements SchedulerLike {
33
35
// Wrap the specified work function to make sure that if nested scheduling takes place the
34
36
// work is executed in the correct zone
35
37
const workInZone = function ( this : SchedulerAction < any > , state : any ) {
36
- targetZone . runGuarded ( ( ) => {
38
+ if ( targetZone ) {
39
+ targetZone . runGuarded ( ( ) => {
40
+ work . apply ( this , [ state ] ) ;
41
+ } ) ;
42
+ } else {
37
43
work . apply ( this , [ state ] ) ;
38
- } ) ;
44
+ }
39
45
} ;
40
46
41
47
// Scheduling itself needs to be run in zone to ensure setInterval calls for async scheduling are done
@@ -73,11 +79,14 @@ export class ɵAngularFireSchedulers {
73
79
constructor ( public ngZone : NgZone , public pendingTasks : ExperimentalPendingTasks ) {
74
80
this . outsideAngular = ngZone . runOutsideAngular (
75
81
// @ts -ignore
76
- ( ) => new ɵZoneScheduler ( Zone . current )
82
+ ( ) => new ɵZoneScheduler ( typeof Zone === 'undefined' ? undefined : Zone . current )
77
83
) ;
78
84
this . insideAngular = ngZone . run (
79
85
// @ts -ignore
80
- ( ) => new ɵZoneScheduler ( Zone . current , asyncScheduler )
86
+ ( ) => new ɵZoneScheduler (
87
+ typeof Zone === 'undefined' ? undefined : Zone . current ,
88
+ asyncScheduler
89
+ )
81
90
) ;
82
91
globalThis . ɵAngularFireScheduler ||= this ;
83
92
}
0 commit comments