1
1
import { Inject , Injectable , InjectionToken , NgZone , Optional , PLATFORM_ID } from '@angular/core' ;
2
2
import { from , Observable , of } from 'rxjs' ;
3
- import { AssociatedReference , CollectionReference , DocumentReference , PersistenceSettings , Query , QueryFn , QueryGroupFn , Settings } from './interfaces' ;
3
+ import {
4
+ AssociatedReference ,
5
+ CollectionReference ,
6
+ DocumentReference ,
7
+ PersistenceSettings ,
8
+ Query ,
9
+ QueryFn ,
10
+ QueryGroupFn ,
11
+ Settings
12
+ } from './interfaces' ;
4
13
import { AngularFirestoreDocument } from './document/document' ;
5
14
import { AngularFirestoreCollection } from './collection/collection' ;
6
15
import { AngularFirestoreCollectionGroup } from './collection-group/collection-group' ;
7
- import { FIREBASE_APP_NAME , FIREBASE_OPTIONS , FirebaseAppConfig , FirebaseOptions , ɵAngularFireSchedulers , ɵfirebaseAppFactory , ɵkeepUnstableUntilFirstFactory } from '@angular/fire' ;
16
+ import {
17
+ FIREBASE_APP_NAME ,
18
+ FIREBASE_OPTIONS ,
19
+ FirebaseAppConfig ,
20
+ FirebaseOptions ,
21
+ ɵAngularFireSchedulers ,
22
+ ɵfirebaseAppFactory ,
23
+ ɵkeepUnstableUntilFirstFactory
24
+ } from '@angular/fire' ;
8
25
import { isPlatformServer } from '@angular/common' ;
9
26
import { firestore } from 'firebase/app' ;
10
27
import firebase from '@firebase/app' ;
@@ -15,7 +32,7 @@ import 'firebase/firestore';
15
32
* The value of this token determines whether or not the firestore will have persistance enabled
16
33
*/
17
34
export const ENABLE_PERSISTENCE = new InjectionToken < boolean > ( 'angularfire2.enableFirestorePersistence' ) ;
18
- export const PERSISTENCE_SETTINGS = new InjectionToken < PersistenceSettings | undefined > ( 'angularfire2.firestore.persistenceSettings' ) ;
35
+ export const PERSISTENCE_SETTINGS = new InjectionToken < PersistenceSettings | undefined > ( 'angularfire2.firestore.persistenceSettings' ) ;
19
36
export const SETTINGS = new InjectionToken < Settings > ( 'angularfire2.firestore.settings' ) ;
20
37
21
38
/**
@@ -107,13 +124,13 @@ export class AngularFirestore {
107
124
*/
108
125
constructor (
109
126
@Inject ( FIREBASE_OPTIONS ) options : FirebaseOptions ,
110
- @Optional ( ) @Inject ( FIREBASE_APP_NAME ) nameOrConfig : string | FirebaseAppConfig | null | undefined ,
111
- @Optional ( ) @Inject ( ENABLE_PERSISTENCE ) shouldEnablePersistence : boolean | null ,
112
- @Optional ( ) @Inject ( SETTINGS ) settings : Settings | null ,
127
+ @Optional ( ) @Inject ( FIREBASE_APP_NAME ) nameOrConfig : string | FirebaseAppConfig | null | undefined ,
128
+ @Optional ( ) @Inject ( ENABLE_PERSISTENCE ) shouldEnablePersistence : boolean | null ,
129
+ @Optional ( ) @Inject ( SETTINGS ) settings : Settings | null ,
113
130
// tslint:disable-next-line:ban-types
114
131
@Inject ( PLATFORM_ID ) platformId : Object ,
115
132
zone : NgZone ,
116
- @Optional ( ) @Inject ( PERSISTENCE_SETTINGS ) persistenceSettings : PersistenceSettings | null ,
133
+ @Optional ( ) @Inject ( PERSISTENCE_SETTINGS ) persistenceSettings : PersistenceSettings | null
117
134
) {
118
135
this . schedulers = new ɵAngularFireSchedulers ( zone ) ;
119
136
this . keepUnstableUntilFirst = ɵkeepUnstableUntilFirstFactory ( this . schedulers , platformId ) ;
@@ -123,9 +140,13 @@ export class AngularFirestore {
123
140
// INVESTIGATE this seems to be required because in the browser build registerFirestore is an Object?
124
141
// seems like we're fighting ngcc. In the server firestore() isn't available, so I have to register
125
142
// in the browser registerFirestore is not a function... maybe this is an underlying firebase-js-sdk issue
126
- if ( registerFirestore ) { registerFirestore ( firebase ) ; }
143
+ if ( registerFirestore ) {
144
+ registerFirestore ( firebase ) ;
145
+ }
127
146
const firestore = app . firestore ( ) ;
128
- if ( settings ) { firestore . settings ( settings ) ; }
147
+ if ( settings ) {
148
+ firestore . settings ( settings ) ;
149
+ }
129
150
return firestore ;
130
151
} ) ;
131
152
@@ -150,7 +171,7 @@ export class AngularFirestore {
150
171
* CollectionReference and an optional query function to narrow the result
151
172
* set.
152
173
*/
153
- collection < T > ( path : string | CollectionReference , queryFn ?: QueryFn ) : AngularFirestoreCollection < T > ;
174
+ collection < T > ( path : string | CollectionReference , queryFn ?: QueryFn ) : AngularFirestoreCollection < T > ;
154
175
collection < T > ( pathOrRef : string | CollectionReference , queryFn ?: QueryFn ) : AngularFirestoreCollection < T > {
155
176
let collectionRef : CollectionReference ;
156
177
if ( typeof pathOrRef === 'string' ) {
@@ -180,6 +201,7 @@ export class AngularFirestore {
180
201
* Collection reference and can be queried.
181
202
*/
182
203
doc < T > ( path : string ) : AngularFirestoreDocument < T > ;
204
+ // tslint:disable-next-line:unified-signatures
183
205
doc < T > ( ref : DocumentReference ) : AngularFirestoreDocument < T > ;
184
206
doc < T > ( pathOrRef : string | DocumentReference ) : AngularFirestoreDocument < T > {
185
207
let ref : DocumentReference ;
0 commit comments