title: Ensure super.onDestroy() in derived component
body: <p>I have bunch of components with very similar lifecycle logic, so I have created my base component, that implements <code>OnDestroy</code></p>
  <pre><code>abstract class BaseComponent implements OnDestroy {
     subscriptions = new Array&lt;Subscription&gt;();
     get model() { return … }
  
     ngOnDestroy() {
        for (let s of subscriptions) s.unsubscribe();
     }
  }
  </code></pre>
  <p>however, when a developers writes custom onOnDestroy method in concrete Component that extends <code>ComponentBase</code>, he has no way to know he need to call <code>super.ngOnDestroy()</code>;</p>
  <p>Is there some (typescript) way to ensure warning? Or pattern other that component inheritance?
  maybe a unit test that would test <code>ngOnDestroy</code> on all components that extends <code>BaseComponent</code>?</p>
  <p><strong>EDIT</strong>
  I came to conslusion, that the <code>BaseComponent</code> with array of subscriptions above is a common antipattern and should be avoided. Ideally using auto unsubscribing observables.</p>
  <p>See this takeUntil(destroy$) pattern:</p>
  <pre><code>class MyComponent implements OnInit, OnDestroy {    
      destroy$ = new Subject();    
    
      constructor(http: HttpService) { }
  
      ngOnInit() {
          http.get(...).pipe(
            takeUntil(this.destroy$)
          ).subscribe(...);  
      }
      
  
      ngOnDestroy() {
        onDestroy$.onNext();
     }
  }
  </code></pre>