MCPcopy Create free account
hub / github.com/angular/components / observe

Method observe

src/cdk/observers/observe-content.ts:98–119  ·  view source on GitHub ↗
(elementOrRef: Element | ElementRef<Element>)

Source from the content-addressed store, hash-verified

96 observe(element: ElementRef<Element>): Observable<MutationRecord[]>;
97
98 observe(elementOrRef: Element | ElementRef<Element>): Observable<MutationRecord[]> {
99 const element = coerceElement(elementOrRef);
100
101 return new Observable((observer: Observer<MutationRecord[]>) => {
102 const stream = this._observeElement(element);
103 const subscription = stream
104 .pipe(
105 map(records => records.filter(record => !shouldIgnoreRecord(record))),
106 filter(records => !!records.length),
107 )
108 .subscribe(records => {
109 this._ngZone.run(() => {
110 observer.next(records);
111 });
112 });
113
114 return () => {
115 subscription.unsubscribe();
116 this._unobserveElement(element);
117 };
118 });
119 }
120
121 /**
122 * Observes the given element by using the existing MutationObserver if available, or creating a

Callers 15

constructorMethod · 0.45
registerColumnFunction · 0.45
constructorMethod · 0.45
constructorMethod · 0.45
constructorMethod · 0.45
constructorMethod · 0.45
startObservingMethod · 0.45
_subscribeToResizeMethod · 0.45
_observeHostResizeMethod · 0.45
_attachOverlayMethod · 0.45
_attachMethod · 0.45

Calls 6

_observeElementMethod · 0.95
_unobserveElementMethod · 0.95
coerceElementFunction · 0.90
shouldIgnoreRecordFunction · 0.85
filterMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected