title: How do I run a function on ngOnInit() only once and not again upon returning back from another routerLink?
body: <p><strong><code>HomeComponent</code></strong></p>
  
  <pre><code>ngOnInit()
  {
      console.log('loaded');
      this.retrieveData();
  }
  
  retrieveData()
  {
      // this.dataService.getData().subscribe(...);
  }
  </code></pre>
  
  <p>I am retrieving data when the component loads. When the user clicks on another <code>routerLink</code>, for example, <code>SettingsComponent</code> and returns back to the <code>HomeComponent</code>, the function of course, is called again because the component has loaded again. But Everytime I return back to the component, it makes the function call again which creates too many unwanted HTTP requests. I need to prevent this and make sure the function is called only the first time. How do I do this? Should I use some other component lifecycle hook?</p>