Angularfire5 config


#1
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule, ModuleWithProviders } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';

import * as firebase from 'firebase/app';
import 'firebase/database';
import 'firebase/auth';
//import { firebaseClient } from './variables/firebaseClient';
import { firebaseGlobal } from './variables/firebaseGlobal';

import { AngularFireModule } from 'angularfire2';
import { AngularFirestoreModule } from 'angularfire2/firestore';

import { MyApp } from './app.component';

import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

/**************/

export const firebaseClient = {
  apiKey: "",
  authDomain: "",
  databaseURL: "",
  projectId: "",
  storageBucket: "",
  messagingSenderId: ""
}
export function initializeFirebaseClient(): ModuleWithProviders {
  firebase.initializeApp(firebaseGlobal);
  firebase.auth().onAuthStateChanged((userClient) => {
    if (!userClient) {
      console.log('auth Global false');
      const ref_promise = firebase.database().ref(`userProfile/fhwPjjC7ugwRtY2wrwtoFcCkyew1`).once('value');
      ref_promise.then(snap => {
        let result = snap.val();
        for (let k in result) {
          firebaseClient[k] = result[k];
        }
        console.log(firebaseClient);
      });
    }
    else {
      console.log('auth Global true');
      const ref_promise = firebase.database().ref(`userProfile/fhwPjjC7ugwRtY2wrwtoFcCkyew1`).once('value');
      ref_promise.then(snap => {
        let result = snap.val();
        for (let k in result) {
          firebaseClient[k] = result[k];
        }
        console.log(firebaseClient);
      });
    }
  })
  return AngularFireModule.initializeApp(firebaseClient, 'firebaseClient');
};

@NgModule({
  declarations: [
    MyApp
  ],
  imports: [
    BrowserModule,
    initializeFirebaseClient(),
    //AngularFireModule.initializeApp(firebaseClient, 'firebaseClient'),
    //AngularFirestoreModule.enablePersistence(),
    IonicModule.forRoot(MyApp),
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp
  ],
  providers: [
    StatusBar,
    SplashScreen,
    { provide: ErrorHandler, useClass: IonicErrorHandler }
  ]
})
export class AppModule { }

hi,
i try to config angularfire for custom config, but : return AngularFireModule.initializeApp(firebaseClient, ‘firebaseClient’);
is done before i have firebaseClient

can you help me please

thanks you

Patrick