source: trip-planner-front/node_modules/@angular/cdk/esm2015/observers/observe-content.js@ bdd6491

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

initial commit

  • Property mode set to 100644
File size: 21.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 { coerceBooleanProperty, coerceNumberProperty, coerceElement } from '@angular/cdk/coercion';
9import { Directive, ElementRef, EventEmitter, Injectable, Input, NgModule, NgZone, Output, } from '@angular/core';
10import { Observable, Subject } from 'rxjs';
11import { debounceTime } from 'rxjs/operators';
12import * as i0 from "@angular/core";
13/**
14 * Factory that creates a new MutationObserver and allows us to stub it out in unit tests.
15 * @docs-private
16 */
17export class MutationObserverFactory {
18 create(callback) {
19 return typeof MutationObserver === 'undefined' ? null : new MutationObserver(callback);
20 }
21}
22MutationObserverFactory.ɵprov = i0.ɵɵdefineInjectable({ factory: function MutationObserverFactory_Factory() { return new MutationObserverFactory(); }, token: MutationObserverFactory, providedIn: "root" });
23MutationObserverFactory.decorators = [
24 { type: Injectable, args: [{ providedIn: 'root' },] }
25];
26/** An injectable service that allows watching elements for changes to their content. */
27export class ContentObserver {
28 constructor(_mutationObserverFactory) {
29 this._mutationObserverFactory = _mutationObserverFactory;
30 /** Keeps track of the existing MutationObservers so they can be reused. */
31 this._observedElements = new Map();
32 }
33 ngOnDestroy() {
34 this._observedElements.forEach((_, element) => this._cleanupObserver(element));
35 }
36 observe(elementOrRef) {
37 const element = coerceElement(elementOrRef);
38 return new Observable((observer) => {
39 const stream = this._observeElement(element);
40 const subscription = stream.subscribe(observer);
41 return () => {
42 subscription.unsubscribe();
43 this._unobserveElement(element);
44 };
45 });
46 }
47 /**
48 * Observes the given element by using the existing MutationObserver if available, or creating a
49 * new one if not.
50 */
51 _observeElement(element) {
52 if (!this._observedElements.has(element)) {
53 const stream = new Subject();
54 const observer = this._mutationObserverFactory.create(mutations => stream.next(mutations));
55 if (observer) {
56 observer.observe(element, {
57 characterData: true,
58 childList: true,
59 subtree: true
60 });
61 }
62 this._observedElements.set(element, { observer, stream, count: 1 });
63 }
64 else {
65 this._observedElements.get(element).count++;
66 }
67 return this._observedElements.get(element).stream;
68 }
69 /**
70 * Un-observes the given element and cleans up the underlying MutationObserver if nobody else is
71 * observing this element.
72 */
73 _unobserveElement(element) {
74 if (this._observedElements.has(element)) {
75 this._observedElements.get(element).count--;
76 if (!this._observedElements.get(element).count) {
77 this._cleanupObserver(element);
78 }
79 }
80 }
81 /** Clean up the underlying MutationObserver for the specified element. */
82 _cleanupObserver(element) {
83 if (this._observedElements.has(element)) {
84 const { observer, stream } = this._observedElements.get(element);
85 if (observer) {
86 observer.disconnect();
87 }
88 stream.complete();
89 this._observedElements.delete(element);
90 }
91 }
92}
93ContentObserver.ɵprov = i0.ɵɵdefineInjectable({ factory: function ContentObserver_Factory() { return new ContentObserver(i0.ɵɵinject(MutationObserverFactory)); }, token: ContentObserver, providedIn: "root" });
94ContentObserver.decorators = [
95 { type: Injectable, args: [{ providedIn: 'root' },] }
96];
97ContentObserver.ctorParameters = () => [
98 { type: MutationObserverFactory }
99];
100/**
101 * Directive that triggers a callback whenever the content of
102 * its associated element has changed.
103 */
104export class CdkObserveContent {
105 constructor(_contentObserver, _elementRef, _ngZone) {
106 this._contentObserver = _contentObserver;
107 this._elementRef = _elementRef;
108 this._ngZone = _ngZone;
109 /** Event emitted for each change in the element's content. */
110 this.event = new EventEmitter();
111 this._disabled = false;
112 this._currentSubscription = null;
113 }
114 /**
115 * Whether observing content is disabled. This option can be used
116 * to disconnect the underlying MutationObserver until it is needed.
117 */
118 get disabled() { return this._disabled; }
119 set disabled(value) {
120 this._disabled = coerceBooleanProperty(value);
121 this._disabled ? this._unsubscribe() : this._subscribe();
122 }
123 /** Debounce interval for emitting the changes. */
124 get debounce() { return this._debounce; }
125 set debounce(value) {
126 this._debounce = coerceNumberProperty(value);
127 this._subscribe();
128 }
129 ngAfterContentInit() {
130 if (!this._currentSubscription && !this.disabled) {
131 this._subscribe();
132 }
133 }
134 ngOnDestroy() {
135 this._unsubscribe();
136 }
137 _subscribe() {
138 this._unsubscribe();
139 const stream = this._contentObserver.observe(this._elementRef);
140 // TODO(mmalerba): We shouldn't be emitting on this @Output() outside the zone.
141 // Consider brining it back inside the zone next time we're making breaking changes.
142 // Bringing it back inside can cause things like infinite change detection loops and changed
143 // after checked errors if people's code isn't handling it properly.
144 this._ngZone.runOutsideAngular(() => {
145 this._currentSubscription =
146 (this.debounce ? stream.pipe(debounceTime(this.debounce)) : stream).subscribe(this.event);
147 });
148 }
149 _unsubscribe() {
150 var _a;
151 (_a = this._currentSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
152 }
153}
154CdkObserveContent.decorators = [
155 { type: Directive, args: [{
156 selector: '[cdkObserveContent]',
157 exportAs: 'cdkObserveContent',
158 },] }
159];
160CdkObserveContent.ctorParameters = () => [
161 { type: ContentObserver },
162 { type: ElementRef },
163 { type: NgZone }
164];
165CdkObserveContent.propDecorators = {
166 event: [{ type: Output, args: ['cdkObserveContent',] }],
167 disabled: [{ type: Input, args: ['cdkObserveContentDisabled',] }],
168 debounce: [{ type: Input }]
169};
170export class ObserversModule {
171}
172ObserversModule.decorators = [
173 { type: NgModule, args: [{
174 exports: [CdkObserveContent],
175 declarations: [CdkObserveContent],
176 providers: [MutationObserverFactory]
177 },] }
178];
179//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib2JzZXJ2ZS1jb250ZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vc3JjL2Nkay9vYnNlcnZlcnMvb2JzZXJ2ZS1jb250ZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFDTCxxQkFBcUIsRUFDckIsb0JBQW9C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