title: Wait for subscription to finish in angular 8
body: <p>I have a component where I am calling a subsriction inside interval in onInit: </p>
  
  <pre><code>  ngOnInit() {    
      interval(5000).pipe(
        takeWhile(() =&gt; this.isAlive))
        .subscribe(() =&gt; {
          this.initialization();
        });    
     }
  
  initialization() {
      this.subscriptions.add(
        this.someService.someMethod().subscribe(
          data =&gt; {
            this.myData = Object.assign({}, data);
            this.var1 = this.myData.x; // Using var1 in HTML to bind to a text element
            this.var2 = this.myData.y; // Using var2 in HTML to bind to a text element
          }
        )
      );
    }
  
  var1Change(value) {
      // Check if my code is in observable, once it is finish, execute save immediately. How to acheive it?
      this.var1 = value;
      this.myData.x = value;
      this.callSave();
  }
  
  callSave() {
      // Method to consume api to save data to file
  }
  </code></pre>
  
  <p>So every 5 seconds my UI is updated whenever there is update in data.<br/>
  I can make the change from UI and save the data to file by consuming API as well and save is happening when there is model change, then only save is happening. There is no save button for it.<br/>
  So what I want If my code is inside the observable, I want to wait for save to happen<br/>
  Please help me with the existing code only as I am bound to use interval and Save call in this way</p>
  
  <p>Using angular 8.2 and rxjs 6.4</p>