title: Prevent memory leaks in Angular 2?
body: <p>In Angular 2 are there any specific pitfalls regarding memory management, I should be aware of?</p>
  
  <p>What are the best practices to manage the state of components in order to avoid possible leaks?</p>
  
  <p>Specifically, I've seen some people <a href="https://stackoverflow.com/a/34402906/352796">unsubscribing from HTTP observables</a> in the <code>ngOnDestroy</code> method. Should I always do that?</p>
  
  <p>In Angular 1.X I know that when a <code>$scope</code> is destroyed, all listeners on it are destroyed as well, automatically. What about observables in Angular 2 components?</p>
  
  <pre><code>@Component({
    selector: 'library',
    template: `
      &lt;tr *ngFor="#book of books | async"&gt;
          &lt;td&gt;{{ book.title.text }}&lt;/td&gt;
          &lt;td&gt;{{ book.author.text }}&lt;/td&gt;
      &lt;/tr&gt;
    `
  })
  export class Library {
      books: Observable&lt;any&gt;;
  
      constructor(private backend: Backend) {
          this.books = this.backend.get('/texts'); // &lt;-- does it get destroyed
                                                   //     with the component?
      }
  };
  </code></pre>