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

Function patchThen

packages/zone.js/lib/common/promise.ts:589–610  ·  view source on GitHub ↗
(Ctor: Function)

Source from the content-addressed store, hash-verified

587 const symbolThenPatched = __symbol__('thenPatched');
588
589 function patchThen(Ctor: Function) {
590 const proto = Ctor.prototype;
591
592 const prop = ObjectGetOwnPropertyDescriptor(proto, 'then');
593 if (prop && (prop.writable === false || !prop.configurable)) {
594 // check Ctor.prototype.then propertyDescriptor is writable or not
595 // in meteor env, writable is false, we should ignore such case
596 return;
597 }
598
599 const originalThen = proto.then;
600 // Keep a reference to the original method.
601 proto[symbolThen] = originalThen;
602
603 Ctor.prototype.then = function (onResolve: any, onReject: any) {
604 const wrapped = new ZoneAwarePromise((resolve, reject) => {
605 originalThen.call(this, resolve, reject);
606 });
607 return wrapped.then(onResolve, onReject);
608 };
609 (Ctor as any)[symbolThenPatched] = true;
610 }
611
612 api.patchThen = patchThen;
613

Callers 2

zoneifyFunction · 0.85
patchPromiseFunction · 0.85

Calls 1

thenMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…