1- import { ApplicationRef , Component , NgZone } from '@angular/core' ;
1+ import { ApplicationRef , Component , NgZone , Optional } from '@angular/core' ;
22import { FirebaseApp , FirebaseApps } from '@angular/fire/app' ;
33import { 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' ;
65import { debounceTime } from 'rxjs/operators' ;
6+ import { initializeFirestore$ } from './firestore' ;
77
88@Component ( {
99 selector : 'app-root' ,
@@ -39,8 +39,8 @@ export class AppComponent {
3939 public auth : Auth , // default Firbase Auth
4040 public apps : FirebaseApps , // all initialized App instances
4141 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 ,
4444 appRef : ApplicationRef ,
4545 zone : NgZone ,
4646 ) {
@@ -50,16 +50,7 @@ export class AppComponent {
5050 authState ( auth ) . subscribe ( it => console . log ( 'authState' , it ) ) ;
5151 appRef . isStable . pipe ( debounceTime ( 200 ) ) . subscribe ( it => console . log ( 'isStable' , it ) ) ;
5252 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 ) ) ;
6455 }
6556}
0 commit comments