@@ -39,35 +39,35 @@ import { RAFirebaseOptions } from '../../options';
3939import { IFirebaseWrapper } from './IFirebaseWrapper' ;
4040
4141export class FirebaseWrapper implements IFirebaseWrapper {
42- private readonly app : FireApp ;
43- private readonly firestore : FireStore ;
44- private readonly storage : FireStorage ;
45- private readonly auth : FireAuth ;
42+ private readonly _app : FireApp ;
43+ private readonly _firestore : FireStore ;
44+ private readonly _storage : FireStorage ;
45+ private readonly _auth : FireAuth ;
4646 public options : RAFirebaseOptions ;
4747
4848 constructor ( inputOptions : RAFirebaseOptions | undefined , firebaseConfig : { } ) {
4949 const optionsSafe = inputOptions || { } ;
5050 this . options = optionsSafe ;
51- this . app = ( window as any ) [ '_app' ] = ObtainFirebaseApp (
51+ this . _app = ( window as any ) [ '_app' ] = ObtainFirebaseApp (
5252 firebaseConfig ,
5353 optionsSafe
5454 ) ;
55- this . firestore = getFirestore ( this . app ) ;
56- this . storage = getStorage ( this . app ) ;
57- this . auth = getAuth ( this . app ) ;
55+ this . _firestore = getFirestore ( this . _app ) ;
56+ this . _storage = getStorage ( this . _app ) ;
57+ this . _auth = getAuth ( this . _app ) ;
5858 }
5959 dbGetCollection ( absolutePath : string ) : FireStoreCollectionRef {
60- return collection ( this . firestore , absolutePath ) ;
60+ return collection ( this . _firestore , absolutePath ) ;
6161 }
6262 dbCreateBatch ( ) : FireStoreBatch {
63- return writeBatch ( this . firestore ) ;
63+ return writeBatch ( this . _firestore ) ;
6464 }
6565 dbMakeNewId ( ) : string {
66- return doc ( collection ( this . firestore , 'collections' ) ) . id ;
66+ return doc ( collection ( this . _firestore , 'collections' ) ) . id ;
6767 }
6868
6969 public OnUserLogout ( callBack : ( u : FireUser | null ) => any ) {
70- this . auth . onAuthStateChanged ( ( user ) => {
70+ this . _auth . onAuthStateChanged ( ( user ) => {
7171 const isLoggedOut = ! user ;
7272 log ( 'FirebaseWrapper.OnUserLogout' , { user, isLoggedOut } ) ;
7373 if ( isLoggedOut ) {
@@ -76,7 +76,7 @@ export class FirebaseWrapper implements IFirebaseWrapper {
7676 } ) ;
7777 }
7878 putFile ( storagePath : string , rawFile : any ) : FireStoragePutFileResult {
79- const task = uploadBytesResumable ( ref ( this . storage , storagePath ) , rawFile ) ;
79+ const task = uploadBytesResumable ( ref ( this . _storage , storagePath ) , rawFile ) ;
8080 const taskResult = new Promise < FireUploadTaskSnapshot > ( ( res , rej ) =>
8181 task . then ( res ) . catch ( rej )
8282 ) ;
@@ -92,7 +92,7 @@ export class FirebaseWrapper implements IFirebaseWrapper {
9292 } ;
9393 }
9494 async getStorageDownloadUrl ( fieldSrc : string ) : Promise < string > {
95- return getDownloadURL ( ref ( this . storage , fieldSrc ) ) ;
95+ return getDownloadURL ( ref ( this . _storage , fieldSrc ) ) ;
9696 }
9797 public serverTimestamp ( ) {
9898 // This line doesn't work for some reason, might be firebase sdk.
@@ -116,25 +116,25 @@ export class FirebaseWrapper implements IFirebaseWrapper {
116116
117117 log ( 'setPersistence' , { persistenceInput, persistenceResolved } ) ;
118118
119- return this . auth
119+ return this . _auth
120120 . setPersistence ( persistenceResolved )
121121 . catch ( ( error ) => console . error ( error ) ) ;
122122 }
123123 async authSigninEmailPassword (
124124 email : string ,
125125 password : string
126126 ) : Promise < FireAuthUserCredentials > {
127- const user = await signInWithEmailAndPassword ( this . auth , email , password ) ;
127+ const user = await signInWithEmailAndPassword ( this . _auth , email , password ) ;
128128 return user ;
129129 }
130130 async authSignOut ( ) : Promise < void > {
131- return signOut ( this . auth ) ;
131+ return signOut ( this . _auth ) ;
132132 }
133133 async authGetUserLoggedIn ( ) : Promise < FireUser > {
134134 return new Promise ( ( resolve , reject ) => {
135- const auth = this . auth ;
135+ const auth = this . _auth ;
136136 if ( auth . currentUser ) return resolve ( auth . currentUser ) ;
137- const unsubscribe = onAuthStateChanged ( this . auth , ( user ) => {
137+ const unsubscribe = onAuthStateChanged ( this . _auth , ( user ) => {
138138 unsubscribe ( ) ;
139139 if ( user ) {
140140 resolve ( user ) ;
@@ -149,17 +149,20 @@ export class FirebaseWrapper implements IFirebaseWrapper {
149149 }
150150
151151 /** @deprecated */
152- public fireStorage ( ) : FireStorage {
153- return this . storage ;
152+ public auth ( ) : FireAuth {
153+ return this . _auth ;
154+ }
155+ /** @deprecated */
156+ public storage ( ) : FireStorage {
157+ return this . _storage ;
154158 }
155-
156159 /** @deprecated */
157160 public GetApp ( ) : FireApp {
158- return this . app ;
161+ return this . _app ;
159162 }
160163 /** @deprecated */
161164 public db ( ) : FireStore {
162- return this . firestore ;
165+ return this . _firestore ;
163166 }
164167}
165168
0 commit comments