import { Component, OnInit, OnDestroy } from '@angular/core'; import { Subject } from 'rxjs/Subject' export abstract class AutoUnsub implements OnDestroy { private _destroy = new Subject(); protected _destroy$ = this._destroy.asObservable(); constructor() { } ngOnDestroy() { this._destroy.next(); this._destroy.complete(); } }