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 | */
|
---|
8 | import { __awaiter } from "tslib";
|
---|
9 | import { BehaviorSubject } from 'rxjs';
|
---|
10 | /** Subject used to dispatch and listen for changes to the auto change detection status . */
|
---|
11 | const autoChangeDetectionSubject = new BehaviorSubject({
|
---|
12 | isDisabled: false
|
---|
13 | });
|
---|
14 | /** The current subscription to `autoChangeDetectionSubject`. */
|
---|
15 | let autoChangeDetectionSubscription;
|
---|
16 | /**
|
---|
17 | * The default handler for auto change detection status changes. This handler will be used if the
|
---|
18 | * specific environment does not install its own.
|
---|
19 | * @param status The new auto change detection status.
|
---|
20 | */
|
---|
21 | function defaultAutoChangeDetectionHandler(status) {
|
---|
22 | var _a;
|
---|
23 | (_a = status.onDetectChangesNow) === null || _a === void 0 ? void 0 : _a.call(status);
|
---|
24 | }
|
---|
25 | /**
|
---|
26 | * Allows a test `HarnessEnvironment` to install its own handler for auto change detection status
|
---|
27 | * changes.
|
---|
28 | * @param handler The handler for the auto change detection status.
|
---|
29 | */
|
---|
30 | export function handleAutoChangeDetectionStatus(handler) {
|
---|
31 | stopHandlingAutoChangeDetectionStatus();
|
---|
32 | autoChangeDetectionSubscription = autoChangeDetectionSubject.subscribe(handler);
|
---|
33 | }
|
---|
34 | /** Allows a `HarnessEnvironment` to stop handling auto change detection status changes. */
|
---|
35 | export function stopHandlingAutoChangeDetectionStatus() {
|
---|
36 | autoChangeDetectionSubscription === null || autoChangeDetectionSubscription === void 0 ? void 0 : autoChangeDetectionSubscription.unsubscribe();
|
---|
37 | autoChangeDetectionSubscription = null;
|
---|
38 | }
|
---|
39 | /**
|
---|
40 | * Batches together triggering of change detection over the duration of the given function.
|
---|
41 | * @param fn The function to call with batched change detection.
|
---|
42 | * @param triggerBeforeAndAfter Optionally trigger change detection once before and after the batch
|
---|
43 | * operation. If false, change detection will not be triggered.
|
---|
44 | * @return The result of the given function.
|
---|
45 | */
|
---|
46 | function batchChangeDetection(fn, triggerBeforeAndAfter) {
|
---|
47 | return __awaiter(this, void 0, void 0, function* () {
|
---|
48 | // If change detection batching is already in progress, just run the function.
|
---|
49 | if (autoChangeDetectionSubject.getValue().isDisabled) {
|
---|
50 | return yield fn();
|
---|
51 | }
|
---|
52 | // If nothing is handling change detection batching, install the default handler.
|
---|
53 | if (!autoChangeDetectionSubscription) {
|
---|
54 | handleAutoChangeDetectionStatus(defaultAutoChangeDetectionHandler);
|
---|
55 | }
|
---|
56 | if (triggerBeforeAndAfter) {
|
---|
57 | yield new Promise(resolve => autoChangeDetectionSubject.next({
|
---|
58 | isDisabled: true,
|
---|
59 | onDetectChangesNow: resolve,
|
---|
60 | }));
|
---|
61 | // The function passed in may throw (e.g. if the user wants to make an expectation of an error
|
---|
62 | // being thrown. If this happens, we need to make sure we still re-enable change detection, so
|
---|
63 | // we wrap it in a `finally` block.
|
---|
64 | try {
|
---|
65 | return yield fn();
|
---|
66 | }
|
---|
67 | finally {
|
---|
68 | yield new Promise(resolve => autoChangeDetectionSubject.next({
|
---|
69 | isDisabled: false,
|
---|
70 | onDetectChangesNow: resolve,
|
---|
71 | }));
|
---|
72 | }
|
---|
73 | }
|
---|
74 | else {
|
---|
75 | autoChangeDetectionSubject.next({ isDisabled: true });
|
---|
76 | // The function passed in may throw (e.g. if the user wants to make an expectation of an error
|
---|
77 | // being thrown. If this happens, we need to make sure we still re-enable change detection, so
|
---|
78 | // we wrap it in a `finally` block.
|
---|
79 | try {
|
---|
80 | return yield fn();
|
---|
81 | }
|
---|
82 | finally {
|
---|
83 | autoChangeDetectionSubject.next({ isDisabled: false });
|
---|
84 | }
|
---|
85 | }
|
---|
86 | });
|
---|
87 | }
|
---|
88 | /**
|
---|
89 | * Disables the harness system's auto change detection for the duration of the given function.
|
---|
90 | * @param fn The function to disable auto change detection for.
|
---|
91 | * @return The result of the given function.
|
---|
92 | */
|
---|
93 | export function manualChangeDetection(fn) {
|
---|
94 | return __awaiter(this, void 0, void 0, function* () {
|
---|
95 | return batchChangeDetection(fn, false);
|
---|
96 | });
|
---|
97 | }
|
---|
98 | /**
|
---|
99 | * Resolves the given list of async values in parallel (i.e. via Promise.all) while batching change
|
---|
100 | * detection over the entire operation such that change detection occurs exactly once before
|
---|
101 | * resolving the values and once after.
|
---|
102 | * @param values A getter for the async values to resolve in parallel with batched change detection.
|
---|
103 | * @return The resolved values.
|
---|
104 | */
|
---|
105 | export function parallel(values) {
|
---|
106 | return __awaiter(this, void 0, void 0, function* () {
|
---|
107 | return batchChangeDetection(() => Promise.all(values()), true);
|
---|
108 | });
|
---|
109 | }
|
---|
110 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hhbmdlLWRldGVjdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9jZGsvdGVzdGluZy9jaGFuZ2UtZGV0ZWN0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRzs7QUFFSCxPQUFPLEVBQUMsZUFBZSxFQUFlLE1BQU0sTUFBTSxDQUFDO0FBY25ELDRGQUE0RjtBQUM1RixNQUFNLDBCQUEwQixHQUFHLElBQUksZUFBZSxDQUE0QjtJQUNoRixVQUFVLEVBQUUsS0FBSztDQUNsQixDQUFDLENBQUM7QUFFSCxnRUFBZ0U7QUFDaEUsSUFBSSwrQkFBb0QsQ0FBQztBQUV6RDs7OztHQUlHO0FBQ0gsU0FBUyxpQ0FBaUMsQ0FBQyxNQUFpQzs7SUFDMUUsTUFBQSxNQUFNLENBQUMsa0JBQWtCLCtDQUF6QixNQUFNLENBQXVCLENBQUM7QUFDaEMsQ0FBQztBQUVEOzs7O0dBSUc7QUFDSCxNQUFNLFVBQVUsK0JBQStCLENBQzNDL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