source: trip-planner-front/node_modules/@angular/cdk/esm2015/table/coalesced-style-scheduler.js@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 9.2 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { Injectable, NgZone, InjectionToken } from '@angular/core';
9import { from, Subject } from 'rxjs';
10import { take, takeUntil } from 'rxjs/operators';
11/**
12 * @docs-private
13 */
14export class _Schedule {
15 constructor() {
16 this.tasks = [];
17 this.endTasks = [];
18 }
19}
20/** Injection token used to provide a coalesced style scheduler. */
21export const _COALESCED_STYLE_SCHEDULER = new InjectionToken('_COALESCED_STYLE_SCHEDULER');
22/**
23 * Allows grouping up CSSDom mutations after the current execution context.
24 * This can significantly improve performance when separate consecutive functions are
25 * reading from the CSSDom and then mutating it.
26 *
27 * @docs-private
28 */
29export class _CoalescedStyleScheduler {
30 constructor(_ngZone) {
31 this._ngZone = _ngZone;
32 this._currentSchedule = null;
33 this._destroyed = new Subject();
34 }
35 /**
36 * Schedules the specified task to run at the end of the current VM turn.
37 */
38 schedule(task) {
39 this._createScheduleIfNeeded();
40 this._currentSchedule.tasks.push(task);
41 }
42 /**
43 * Schedules the specified task to run after other scheduled tasks at the end of the current
44 * VM turn.
45 */
46 scheduleEnd(task) {
47 this._createScheduleIfNeeded();
48 this._currentSchedule.endTasks.push(task);
49 }
50 /** Prevent any further tasks from running. */
51 ngOnDestroy() {
52 this._destroyed.next();
53 this._destroyed.complete();
54 }
55 _createScheduleIfNeeded() {
56 if (this._currentSchedule) {
57 return;
58 }
59 this._currentSchedule = new _Schedule();
60 this._getScheduleObservable().pipe(takeUntil(this._destroyed)).subscribe(() => {
61 while (this._currentSchedule.tasks.length || this._currentSchedule.endTasks.length) {
62 const schedule = this._currentSchedule;
63 // Capture new tasks scheduled by the current set of tasks.
64 this._currentSchedule = new _Schedule();
65 for (const task of schedule.tasks) {
66 task();
67 }
68 for (const task of schedule.endTasks) {
69 task();
70 }
71 }
72 this._currentSchedule = null;
73 });
74 }
75 _getScheduleObservable() {
76 // Use onStable when in the context of an ongoing change detection cycle so that we
77 // do not accidentally trigger additional cycles.
78 return this._ngZone.isStable ?
79 from(Promise.resolve(undefined)) :
80 this._ngZone.onStable.pipe(take(1));
81 }
82}
83_CoalescedStyleScheduler.decorators = [
84 { type: Injectable }
85];
86_CoalescedStyleScheduler.ctorParameters = () => [
87 { type: NgZone }
88];
89//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29hbGVzY2VkLXN0eWxlLXNjaGVkdWxlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9jZGsvdGFibGUvY29hbGVzY2VkLXN0eWxlLXNjaGVkdWxlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQUMsVUFBVSxFQUFFLE1BQU0sRUFBYSxjQUFjLEVBQUMsTUFBTSxlQUFlLENBQUM7QUFDNUUsT0FBTyxFQUFDLElBQUksRUFBRSxPQUFPLEVBQUMsTUFBTSxNQUFNLENBQUM7QUFDbkMsT0FBTyxFQUFDLElBQUksRUFBRSxTQUFTLEVBQUMsTUFBTSxnQkFBZ0IsQ0FBQztBQUUvQzs7R0FFRztBQUNILE1BQU0sT0FBTyxTQUFTO0lBQXRCO1FBQ0UsVUFBSyxHQUFzQixFQUFFLENBQUM7UUFDOUIsYUFBUSxHQUFzQixFQUFFLENBQUM7SUFDbkMsQ0FBQztDQUFBO0FBRUQsbUVBQW1FO0FBQ25FLE1BQU0sQ0FBQyxNQUFNLDBCQUEwQixHQUNuQyxJQUFJLGNBQWMsQ0FBMkIsNEJBQTRCLENBQUMsQ0FBQztBQUUvRTs7Ozs7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sZSgpIHtcbiAgICAvLyBVc2Ugb25TdGFibGUgd2hlbiBpbiB0aGUgY29udGV4dCBvZiBhbiBvbmdvaW5nIGNoYW5nZSBkZXRlY3Rpb24gY3ljbGUgc28gdGhhdCB3ZVxuICAgIC8vIGRvIG5vdCBhY2NpZGVudGFsbHkgdHJpZ2dlciBhZGRpdGlvbmFsIGN5Y2xlcy5cbiAgICByZXR1cm4gdGhpcy5fbmdab25lLmlzU3RhYmxlID9cbiAgICAgICAgZnJvbShQcm9taXNlLnJlc29sdmUodW5kZWZpbmVkKSkgOlxuICAgICAgICB0aGlzLl9uZ1pvbmUub25TdGFibGUucGlwZSh0YWtlKDEpKTtcbiAgfVxufVxuIl19
Note: See TracBrowser for help on using the repository browser.