import { Timer } from '@deepkit/core' ; import { Observer } from 'rxjs' ; /**
 * Allows to create Timer which get deactivated automatically
 * when the observer is stopped.
 */ export class ObserverTimer extends Timer { constructor ( protected observer ) { super ( ) ; } setTimeout ( cb , timeout ) { super . setTimeout ( ( ) => { if ( ! this . observer . closed ) { cb ( ) ; } } , timeout ) ; } }