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

Function scheduleResolveOrReject

packages/zone.js/lib/common/promise.ts:274–318  ·  view source on GitHub ↗
(
      promise: ZoneAwarePromise<any>,
      zone: Zone,
      chainPromise: ZoneAwarePromise<any>,
      onFulfilled?: ((value: R) => U1) | null | undefined,
      onRejected?: ((error: any) => U2) | null | undefined,
    )

Source from the content-addressed store, hash-verified

272 }
273
274 function scheduleResolveOrReject<R, U1, U2>(
275 promise: ZoneAwarePromise<any>,
276 zone: Zone,
277 chainPromise: ZoneAwarePromise<any>,
278 onFulfilled?: ((value: R) => U1) | null | undefined,
279 onRejected?: ((error: any) => U2) | null | undefined,
280 ): void {
281 clearRejectedNoCatch(promise);
282 const promiseState = (promise as any)[symbolState];
283 const delegate = promiseState
284 ? typeof onFulfilled === 'function'
285 ? onFulfilled
286 : forwardResolution
287 : typeof onRejected === 'function'
288 ? onRejected
289 : forwardRejection;
290 zone.scheduleMicroTask(
291 source,
292 () => {
293 try {
294 const parentPromiseValue = (promise as any)[symbolValue];
295 const isFinallyPromise =
296 !!chainPromise && symbolFinally === (chainPromise as any)[symbolFinally];
297 if (isFinallyPromise) {
298 // if the promise is generated from finally call, keep parent promise's state and value
299 (chainPromise as any)[symbolParentPromiseValue] = parentPromiseValue;
300 (chainPromise as any)[symbolParentPromiseState] = promiseState;
301 }
302 // should not pass value to finally callback
303 const value = zone.run(
304 delegate,
305 undefined,
306 isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution
307 ? []
308 : [parentPromiseValue],
309 );
310 resolvePromise(chainPromise, true, value);
311 } catch (error) {
312 // if error occurs, should always return this error
313 resolvePromise(chainPromise, false, error);
314 }
315 },
316 chainPromise as TaskData,
317 );
318 }
319
320 const ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }';
321

Callers 3

resolvePromiseFunction · 0.85
thenMethod · 0.85
finallyMethod · 0.85

Calls 4

clearRejectedNoCatchFunction · 0.85
resolvePromiseFunction · 0.85
scheduleMicroTaskMethod · 0.65
runMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…