title: Wait for a stream before invoking another stream
body: <p>How do I wait for one stream (say, <code>StreamA</code>) to return non-null value and then invoke <code>StreamB</code> subscribe function. I'm not particularly interested in <code>StreamA</code>'s value. In turn, I am trying to get <code>StreamB</code>'s value which might have been updated before the StreamA returned non-null value, and might not have any new events. </p>
  
  <p>I tried, <em>pausable</em>, by looking at this: <a href="https://stackoverflow.com/questions/28315026/rxjs-how-can-i-do-an-if-with-observables">RxJS: How can I do an &quot;if&quot; with Observables?</a>, but unfortunately could not get it to work. This is because, there are no exported class <code>pausable</code>, rxjs v 5.0.0-beta.6.</p>
  
  <p>This is how far, I've come up with, as per the answer.</p>
  
  <p>export class AuthService {
        userModel: FirebaseListObservable = this.af.database.list(<code>/users</code>);
        constructor(private af: AngularFire) {</p>
  
  <pre><code>    var user = this.currentAuthor();
      var userStream = user;
  
      this.af.auth.flatMap((d) =&gt; { console.log(d);return this.userModel.publishReplay(1); });
  
      this.userModel
        .subscribe((data) =&gt; {
          var flag = false;
          data.forEach((item) =&gt; {
            if (item.$key &amp;&amp; item.$key === user.uid) {
              flag = true;
              return;
            }
          });
  
          if (flag) {
            console.log('hello');
          } else {
            this.userModel.push({
                firstName: user.auth.displayName.substr(0, user.auth.displayName.lastIndexOf(' ')),
                lastName: user.auth.displayName.substr(user.auth.displayName.lastIndexOf(' '), user.auth.displayName.length),
                displayPic: user.auth.photoURL,
                provider: user.provider,
                uid: user.uid
              }
            );
          }
        })
    }
    public currentAuthor():FirebaseAuthState  {
      return this.af.auth.getAuth();
    }
  </code></pre>
  
  <p>Hope, I can make myself clear. Even I am getting confused now. :p.</p>
  
  <p>I am new to rxjs and reactive programming. And, any help will be appreciated.</p>
  
  <p>And, btw, thanks for stopping by. :)</p>