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

Function patchObservable

packages/zone.js/lib/rxjs/rxjs.ts:26–97  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24 const ObjectDefineProperties = Object.defineProperties;
25
26 const patchObservable = function () {
27 const ObservablePrototype: any = Observable.prototype;
28 const _symbolSubscribe = symbol('_subscribe');
29 const _subscribe = (ObservablePrototype[_symbolSubscribe] = ObservablePrototype._subscribe);
30
31 ObjectDefineProperties(Observable.prototype, {
32 _zone: {value: null, writable: true, configurable: true},
33 _zoneSource: {value: null, writable: true, configurable: true},
34 _zoneSubscribe: {value: null, writable: true, configurable: true},
35 source: {
36 configurable: true,
37 get: function (this: Observable<any>) {
38 return (this as any)._zoneSource;
39 },
40 set: function (this: Observable<any>, source: any) {
41 (this as any)._zone = Zone.current;
42 (this as any)._zoneSource = source;
43 },
44 },
45 _subscribe: {
46 configurable: true,
47 get: function (this: Observable<any>) {
48 if ((this as any)._zoneSubscribe) {
49 return (this as any)._zoneSubscribe;
50 } else if (this.constructor === Observable) {
51 return _subscribe;
52 }
53 const proto = Object.getPrototypeOf(this);
54 return proto && proto._subscribe;
55 },
56 set: function (this: Observable<any>, subscribe: any) {
57 (this as any)._zone = Zone.current;
58 if (!subscribe) {
59 (this as any)._zoneSubscribe = subscribe;
60 } else {
61 (this as any)._zoneSubscribe = function (this: ZoneSubscriberContext) {
62 if (this._zone && this._zone !== Zone.current) {
63 const tearDown = this._zone.run(subscribe, this, arguments as any);
64 if (typeof tearDown === 'function') {
65 const zone = this._zone;
66 return function (this: ZoneSubscriberContext) {
67 if (zone !== Zone.current) {
68 return zone.run(tearDown, this, arguments as any);
69 }
70 return tearDown.apply(this, arguments);
71 };
72 } else {
73 return tearDown;
74 }
75 } else {
76 return subscribe.apply(this, arguments);
77 }
78 };
79 }
80 },
81 },
82 subjectFactory: {
83 get: function () {

Callers 1

patchRxJsFunction · 0.85

Calls 2

runMethod · 0.65
applyMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…