title: Wait for firestore data before calling view
body: <p>Whenever my app is launched I want to get the user data from firestore. So in my <code>app.component.ts</code> I have:</p>
  
  <pre><code>constructor(private platform: Platform, ..., private auth: AuthService, private firebaseServie: FirebaseService, private sessionData: SessiondataProvider) {
  
      //Here i call a function that I have in a service:
      if(this.sessionData.currentUser == undefined || this.sessionData.currentUser == null || this.sessionData.currentUser == ""){
        this.firebaseServie.setUserData(user.email);
      }
      //And then I start the ProfilePage View:
      this.rootPage = ProfilePage;
  </code></pre>
  
  <p>The service functipn <code>setUserData</code> calls an asynchronous request to firestore:</p>
  
  <pre><code>  setUserData(email) {
      this.userCollection = this.afs.collection('users', ref =&gt; ref.where('email', '==', email));
      this.userCollection.valueChanges().subscribe((item =&gt; {
        this.users = item;
        this.sessionData.currentUser = this.users[0].username;
      }));
    }
  </code></pre>
  
  <p>So the service function sets the global variable <code>currentUser</code>. In <code>app.component.ts</code> I want to be sure that the <code>currentUser</code> variable has been set, BEFORE launching the <code>ProfilePage</code> view. How can I accomplish that?</p>