source: trip-planner-front/node_modules/rxjs/_esm5/internal/Observable.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/** PURE_IMPORTS_START _util_canReportError,_util_toSubscriber,_symbol_observable,_util_pipe,_config PURE_IMPORTS_END */
2import { canReportError } from './util/canReportError';
3import { toSubscriber } from './util/toSubscriber';
4import { observable as Symbol_observable } from './symbol/observable';
5import { pipeFromArray } from './util/pipe';
6import { config } from './config';
7var Observable = /*@__PURE__*/ (function () {
8 function Observable(subscribe) {
9 this._isScalar = false;
10 if (subscribe) {
11 this._subscribe = subscribe;
12 }
13 }
14 Observable.prototype.lift = function (operator) {
15 var observable = new Observable();
16 observable.source = this;
17 observable.operator = operator;
18 return observable;
19 };
20 Observable.prototype.subscribe = function (observerOrNext, error, complete) {
21 var operator = this.operator;
22 var sink = toSubscriber(observerOrNext, error, complete);
23 if (operator) {
24 sink.add(operator.call(sink, this.source));
25 }
26 else {
27 sink.add(this.source || (config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
28 this._subscribe(sink) :
29 this._trySubscribe(sink));
30 }
31 if (config.useDeprecatedSynchronousErrorHandling) {
32 if (sink.syncErrorThrowable) {
33 sink.syncErrorThrowable = false;
34 if (sink.syncErrorThrown) {
35 throw sink.syncErrorValue;
36 }
37 }
38 }
39 return sink;
40 };
41 Observable.prototype._trySubscribe = function (sink) {
42 try {
43 return this._subscribe(sink);
44 }
45 catch (err) {
46 if (config.useDeprecatedSynchronousErrorHandling) {
47 sink.syncErrorThrown = true;
48 sink.syncErrorValue = err;
49 }
50 if (canReportError(sink)) {
51 sink.error(err);
52 }
53 else {
54 console.warn(err);
55 }
56 }
57 };
58 Observable.prototype.forEach = function (next, promiseCtor) {
59 var _this = this;
60 promiseCtor = getPromiseCtor(promiseCtor);
61 return new promiseCtor(function (resolve, reject) {
62 var subscription;
63 subscription = _this.subscribe(function (value) {
64 try {
65 next(value);
66 }
67 catch (err) {
68 reject(err);
69 if (subscription) {
70 subscription.unsubscribe();
71 }
72 }
73 }, reject, resolve);
74 });
75 };
76 Observable.prototype._subscribe = function (subscriber) {
77 var source = this.source;
78 return source && source.subscribe(subscriber);
79 };
80 Observable.prototype[Symbol_observable] = function () {
81 return this;
82 };
83 Observable.prototype.pipe = function () {
84 var operations = [];
85 for (var _i = 0; _i < arguments.length; _i++) {
86 operations[_i] = arguments[_i];
87 }
88 if (operations.length === 0) {
89 return this;
90 }
91 return pipeFromArray(operations)(this);
92 };
93 Observable.prototype.toPromise = function (promiseCtor) {
94 var _this = this;
95 promiseCtor = getPromiseCtor(promiseCtor);
96 return new promiseCtor(function (resolve, reject) {
97 var value;
98 _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
99 });
100 };
101 Observable.create = function (subscribe) {
102 return new Observable(subscribe);
103 };
104 return Observable;
105}());
106export { Observable };
107function getPromiseCtor(promiseCtor) {
108 if (!promiseCtor) {
109 promiseCtor = config.Promise || Promise;
110 }
111 if (!promiseCtor) {
112 throw new Error('no Promise impl found');
113 }
114 return promiseCtor;
115}
116//# sourceMappingURL=Observable.js.map
Note: See TracBrowser for help on using the repository browser.