1
- import { ApplicationRef , Component , NgZone } from '@angular/core' ;
1
+ import { ApplicationRef , Component , NgZone , Optional } from '@angular/core' ;
2
2
import { FirebaseApp , FirebaseApps } from '@angular/fire/app' ;
3
3
import { Auth , AuthInstances , authState } from '@angular/fire/auth' ;
4
- import { Firestore , FirestoreInstances } from '@angular/fire/firestore' ;
5
- import { functionInstance$ } from '@angular/fire/functions' ;
4
+ import { Firestore , FirestoreInstances , firestoreInstance$ } from '@angular/fire/firestore' ;
6
5
import { debounceTime } from 'rxjs/operators' ;
6
+ import { initializeFirestore$ } from './firestore' ;
7
7
8
8
@Component ( {
9
9
selector : 'app-root' ,
@@ -39,8 +39,8 @@ export class AppComponent {
39
39
public auth : Auth , // default Firbase Auth
40
40
public apps : FirebaseApps , // all initialized App instances
41
41
public authInstances : AuthInstances , // all initialized Auth instances
42
- public firestore : Firestore ,
43
- public firestoreInstances : FirestoreInstances ,
42
+ @ Optional ( ) public firestore : Firestore ,
43
+ @ Optional ( ) public firestoreInstances : FirestoreInstances ,
44
44
appRef : ApplicationRef ,
45
45
zone : NgZone ,
46
46
) {
@@ -50,16 +50,7 @@ export class AppComponent {
50
50
authState ( auth ) . subscribe ( it => console . log ( 'authState' , it ) ) ;
51
51
appRef . isStable . pipe ( debounceTime ( 200 ) ) . subscribe ( it => console . log ( 'isStable' , it ) ) ;
52
52
console . log ( ( app as any ) . container . providers . keys ( ) ) ;
53
- zone . runOutsideAngular ( ( ) => {
54
- setTimeout ( async ( ) => {
55
- const functions = await import ( './getFunctions' ) ;
56
- functions . getFunctions ( app ) ;
57
- } , 5000 ) ;
58
- setTimeout ( async ( ) => {
59
- const functions = await import ( './getFunctions' ) ;
60
- functions . getFunctions ( app , 'asdf' ) ;
61
- } , 10000 ) ;
62
- } ) ;
63
- functionInstance$ . subscribe ( it => console . log ( '$' , it ) ) ;
53
+ firestoreInstance$ . subscribe ( it => console . log ( '$' , it ) ) ;
54
+ initializeFirestore$ . subscribe ( it => console . log ( 'init' , it ) ) ;
64
55
}
65
56
}
0 commit comments