title: Angular listen to function that returns some variable
body: <p>So I have a function in my service that's returning a value and I want my component to be listening to  the value and update it when it changes so I thought It would be a good idea to subscribe to it but it doesn't work as intended and doesn't update the value when it changes. Is there a different way to do this?</p>
  <pre><code> ngOnInit(): void {
      this.translateService.onLangChange.subscribe(() =&gt; this.getLocaleDateFormat());
    }
  
   getLocaleDateFormat(): Observable&lt;string&gt; {
     this.dateAdapter.setLocale(Languages[this.translateService.currentLang]);
     this.currLang = Languages[this.translateService.currentLang];
      console.log( 'get' + this.currLang);
      return of (this.currLang);
  
    }
  
  ngOnInit(): void {
      this.localeDateAdapterService.getLocaleDateFormat().subscribe(currLang =&gt; this.currLang = currLang);
  }
  </code></pre>
  <p>I don't need to know when it changes I just the value to update when it changes. Without using a timer and also without using OnLangChange as a trigger:</p>
  <pre><code>ngOnInit(): void {
   this.translateService.onLangChange.subscribe(() =&gt; this.localeDateAdapterService.getLocaleDateFormat().subscribe(currLang =&gt; this.currLang = currLang));
  }
  </code></pre>