@@ -2,13 +2,16 @@ import { NgZone } from '@angular/core';
2
2
import { asyncScheduler , Observable , Operator , queueScheduler , SchedulerAction , SchedulerLike , Subscriber , Subscription , TeardownLogic } from 'rxjs' ;
3
3
import { observeOn , subscribeOn , tap } from 'rxjs/operators' ;
4
4
5
- function noop ( ) { }
5
+ function noop ( ) {
6
+ }
6
7
7
8
/**
8
9
* Schedules tasks so that they are invoked inside the Zone that is passed in the constructor.
9
10
*/
11
+ // tslint:disable-next-line:class-name
10
12
export class ɵZoneScheduler implements SchedulerLike {
11
- constructor ( private zone : any , private delegate : any = queueScheduler ) { }
13
+ constructor ( private zone : any , private delegate : any = queueScheduler ) {
14
+ }
12
15
13
16
now ( ) {
14
17
return this . delegate . now ( ) ;
@@ -31,17 +34,19 @@ export class ɵZoneScheduler implements SchedulerLike {
31
34
}
32
35
}
33
36
37
+ // tslint:disable-next-line:class-name
34
38
export class ɵBlockUntilFirstOperator < T > implements Operator < T , T > {
35
39
private task : MacroTask | null = null ;
36
40
37
- constructor ( private zone : any ) { }
41
+ constructor ( private zone : any ) {
42
+ }
38
43
39
44
call ( subscriber : Subscriber < T > , source : Observable < T > ) : TeardownLogic {
40
45
const unscheduleTask = this . unscheduleTask . bind ( this ) ;
41
46
this . task = this . zone . run ( ( ) => Zone . current . scheduleMacroTask ( 'firebaseZoneBlock' , noop , { } , noop , noop ) ) ;
42
47
43
48
return source . pipe (
44
- tap ( unscheduleTask , unscheduleTask , unscheduleTask )
49
+ tap ( { next : unscheduleTask , complete : unscheduleTask , error : unscheduleTask } )
45
50
) . subscribe ( subscriber ) . add ( unscheduleTask ) ;
46
51
}
47
52
@@ -57,6 +62,7 @@ export class ɵBlockUntilFirstOperator<T> implements Operator<T, T> {
57
62
}
58
63
}
59
64
65
+ // tslint:disable-next-line:class-name
60
66
export class ɵAngularFireSchedulers {
61
67
public readonly outsideAngular : ɵZoneScheduler ;
62
68
public readonly insideAngular : ɵZoneScheduler ;
@@ -75,6 +81,7 @@ export class ɵAngularFireSchedulers {
75
81
*/
76
82
export function ɵkeepUnstableUntilFirstFactory (
77
83
schedulers : ɵAngularFireSchedulers ,
84
+ // tslint:disable-next-line:ban-types
78
85
platformId : Object
79
86
) {
80
87
return function keepUnstableUntilFirst < T > ( obs$ : Observable < T > ) : Observable < T > {
@@ -93,14 +100,20 @@ export function ɵkeepUnstableUntilFirstFactory(
93
100
} ;
94
101
}
95
102
103
+ // tslint:disable:ban-types
96
104
type FunctionPropertyNames < T > = { [ K in keyof T ] : T [ K ] extends Function ? K : never } [ keyof T ] ;
97
- type PromiseReturningFunctionPropertyNames < T > = { [ K in FunctionPropertyNames < T > ] : ReturnType < T [ K ] > extends Promise < any > ? K : never } [ FunctionPropertyNames < T > ] ;
98
- type NonPromiseReturningFunctionPropertyNames < T > = { [ K in FunctionPropertyNames < T > ] : ReturnType < T [ K ] > extends Promise < any > ? never : K } [ FunctionPropertyNames < T > ] ;
105
+ type PromiseReturningFunctionPropertyNames < T > = {
106
+ [ K in FunctionPropertyNames < T > ] : ReturnType < T [ K ] > extends Promise < any > ? K : never
107
+ } [ FunctionPropertyNames < T > ] ;
108
+ type NonPromiseReturningFunctionPropertyNames < T > = {
109
+ [ K in FunctionPropertyNames < T > ] : ReturnType < T [ K ] > extends Promise < any > ? never : K
110
+ } [ FunctionPropertyNames < T > ] ;
99
111
type NonFunctionPropertyNames < T > = { [ K in keyof T ] : T [ K ] extends Function ? never : K } [ keyof T ] ;
112
+ // tslint:enable:ban-types
100
113
101
114
export type ɵPromiseProxy < T > = { [ K in NonFunctionPropertyNames < T > ] : Promise < T [ K ] > } &
102
115
{ [ K in NonPromiseReturningFunctionPropertyNames < T > ] : ( ...args : Parameters < T [ K ] > ) => Promise < ReturnType < T [ K ] > > } &
103
- { [ K in PromiseReturningFunctionPropertyNames < T > ] : ( ...args : Parameters < T [ K ] > ) => ReturnType < T [ K ] > } ;
116
+ { [ K in PromiseReturningFunctionPropertyNames < T > ] : ( ...args : Parameters < T [ K ] > ) => ReturnType < T [ K ] > } ;
104
117
105
118
106
119
// DEBUG quick debugger function for inline logging that typescript doesn't complain about
@@ -118,12 +131,17 @@ const noopFunctions = ['ngOnDestroy'];
118
131
export const ɵlazySDKProxy = ( klass : any , observable : Observable < any > , zone : NgZone ) => {
119
132
return new Proxy ( klass , {
120
133
get : ( _ , name : string ) => zone . runOutsideAngular ( ( ) => {
121
- if ( klass [ name ] ) { return klass [ name ] ; }
122
- if ( noopFunctions . includes ( name ) ) { return ( ) => { } ; }
134
+ if ( klass [ name ] ) {
135
+ return klass [ name ] ;
136
+ }
137
+ if ( noopFunctions . includes ( name ) ) {
138
+ return ( ) => {
139
+ } ;
140
+ }
123
141
const promise = observable . toPromise ( ) . then ( mod => {
124
142
const ret = mod && mod [ name ] ;
125
143
// TODO move to proper type guards
126
- if ( typeof ret == 'function' ) {
144
+ if ( typeof ret === 'function' ) {
127
145
return ret . bind ( mod ) ;
128
146
} else if ( ret && ret . then ) {
129
147
return ret . then ( ( res : any ) => zone . run ( ( ) => res ) ) ;
0 commit comments