import { ApplicationRef , Injectable , NgZone } from '@angular/core' ; import { EMPTY , Observable , Subscription } from 'rxjs' ; import { switchMap } from 'rxjs/operators' ; Input @ Injectable ( { providedIn : 'root' } ) export class EntryZoneService { constructor ( private zone , private applicationRef ) { } registerZone ( microtaskEmpty$$ ) { return microtaskEmpty$$ . pipe ( switchMap ( ( microtaskEmpty$ ) => microtaskEmpty$ ?? EMPTY ) ) . subscribe ( ( ) => { this . zone . run ( ( ) => { this . applicationRef . tick ( ) ; } ) ; } ) ; } }