title: How to get value outside typescript subscribe function
body: <p>I have the following subscribe function for some service. </p>
  
  <pre><code>this.sub = this.route.params.subscribe(params =&gt; {
  this.id = params['id'];
  this._someService
        .thisById(this.id)
        .subscribe(value =&gt; {
           this.valueObj = value; 
       });
  });
  </code></pre>
  
  <p>This seems all right. Except that I need to use the <strong><em>this.valueObj</em></strong> in the following functions outside the subscribe function.</p>
  
  <pre><code>private  _checkOpeningHours(data: any): string {
      const curDayName = this._getDayName();
      const todaysOpeningData = ***this.valueObj***.openHours[curDayName];
  
      if (!todaysOpeningData) return "ERROR!";
      if (!todaysOpeningData.status) return `IT'S ${curDayName.toUpperCase()} - WE ARE CLOSED TODAY!`;
  
      return `IT'S ${curDayName.toUpperCase()}, ${new Date().toLocaleString("en-US", { hour: '2-digit', minute: '2-digit' })} - ${this._isOpen(todaysOpeningData) ? 'WE ARE OPEN' : 'SORRY, WE ARE CLOSED'}!`;
  
    }
  
    private _refresh() {
      this.opening = this._checkOpeningHours(***this.valueObj***.openHours[this._getDayName()]);
  
      setTimeout(() =&gt; this._refresh(), 60 * 1000);
    }
  </code></pre>
  
  <p>How can I get these functions to work with the <strong><em>this.valueObj</em></strong>?</p>