MCPcopy Index your code
hub / github.com/angular/angular / subscribe

Method subscribe

packages/core/src/event_emitter.ts:144–175  ·  view source on GitHub ↗
(observerOrNext?: any, error?: any, complete?: any)

Source from the content-addressed store, hash-verified

142 }
143
144 override subscribe(observerOrNext?: any, error?: any, complete?: any): Subscription {
145 let nextFn = observerOrNext;
146 let errorFn = error || (() => null);
147 let completeFn = complete;
148
149 if (observerOrNext && typeof observerOrNext === 'object') {
150 const observer = observerOrNext as PartialObserver<unknown>;
151 nextFn = observer.next?.bind(observer);
152 errorFn = observer.error?.bind(observer);
153 completeFn = observer.complete?.bind(observer);
154 }
155
156 if (this.__isAsync) {
157 errorFn = this.wrapInTimeout(errorFn);
158
159 if (nextFn) {
160 nextFn = this.wrapInTimeout(nextFn);
161 }
162
163 if (completeFn) {
164 completeFn = this.wrapInTimeout(completeFn);
165 }
166 }
167
168 const sink = super.subscribe({next: nextFn, error: errorFn, complete: completeFn});
169
170 if (observerOrNext instanceof Subscription) {
171 observerOrNext.add(sink);
172 }
173
174 return sink;
175 }
176
177 private wrapInTimeout(fn: (value: unknown) => any) {
178 return (value: unknown) => {

Callers

nothing calls this directly

Calls 4

wrapInTimeoutMethod · 0.95
bindMethod · 0.65
subscribeMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected