/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { BehaviorSubject } from 'rxjs'; import { Injectable } from './di'; import * as i0 from "./r3_symbols"; /** * *Internal* service that keeps track of pending tasks happening in the system * during the initial rendering. No tasks are tracked after an initial * rendering. * * This information is needed to make sure that the serialization on the server * is delayed until all tasks in the queue (such as an initial navigation or a * pending HTTP request) are completed. */ export class InitialRenderPendingTasks { constructor() { this.taskId = 0; this.pendingTasks = new Set(); this.hasPendingTasks = new BehaviorSubject(false); } add() { this.hasPendingTasks.next(true); const taskId = this.taskId++; this.pendingTasks.add(taskId); return taskId; } remove(taskId) { this.pendingTasks.delete(taskId); if (this.pendingTasks.size === 0) { this.hasPendingTasks.next(false); } } ngOnDestroy() { this.pendingTasks.clear(); this.hasPendingTasks.next(false); } static { this.ɵfac = function InitialRenderPendingTasks_Factory(t) { return new (t || InitialRenderPendingTasks)(); }; } static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: InitialRenderPendingTasks, factory: InitialRenderPendingTasks.ɵfac, providedIn: 'root' }); } } (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.setClassMetadata(InitialRenderPendingTasks, [{ type: Injectable, args: [{ providedIn: 'root' }] }], null, null); })(); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5pdGlhbF9yZW5kZXJfcGVuZGluZ190YXNrcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvcmUvc3JjL2luaXRpYWxfcmVuZGVyX3BlbmRpbmdfdGFza3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUFDLGVBQWUsRUFBQyxNQUFNLE1BQU0sQ0FBQztBQUVyQyxPQUFPLEVBQUMsVUFBVSxFQUFD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