import { Subscription } from 'rxjs' ; import { Clearable } from './clearable' ; /**
 *
 * A parent class for sub-classes who would want to track
 * some [`Subscription`s](https://rxjs-dev.firebaseapp.com/guide/subscription)
 * and clear them later.
 *
 */ export class Tracker implements Clearable { _sub : Subscription | undefined ; param sub returns protected track ( sub ) { if ( ! this . _sub ) { this . _sub = new Subscription ( ) ; } this . _sub . add ( sub ) ; return sub ; } param sub protected untrack ( sub ) { if ( this . _sub ) this . _sub . remove ( sub ) ; return this ; } returns returns returns protected get tracking ( ) : boolean { return ! ! this . _sub ; } warning public clear ( ) { if ( this . _sub ) { this . _sub . unsubscribe ( ) ; this . _sub = undefined ; } return this ; } }