source: trip-planner-front/node_modules/rxjs/_esm5/internal/operators/repeatWhen.js@ 8d391a1

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

initial commit

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/** PURE_IMPORTS_START tslib,_Subject,_innerSubscribe PURE_IMPORTS_END */
2import * as tslib_1 from "tslib";
3import { Subject } from '../Subject';
4import { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';
5export function repeatWhen(notifier) {
6 return function (source) { return source.lift(new RepeatWhenOperator(notifier)); };
7}
8var RepeatWhenOperator = /*@__PURE__*/ (function () {
9 function RepeatWhenOperator(notifier) {
10 this.notifier = notifier;
11 }
12 RepeatWhenOperator.prototype.call = function (subscriber, source) {
13 return source.subscribe(new RepeatWhenSubscriber(subscriber, this.notifier, source));
14 };
15 return RepeatWhenOperator;
16}());
17var RepeatWhenSubscriber = /*@__PURE__*/ (function (_super) {
18 tslib_1.__extends(RepeatWhenSubscriber, _super);
19 function RepeatWhenSubscriber(destination, notifier, source) {
20 var _this = _super.call(this, destination) || this;
21 _this.notifier = notifier;
22 _this.source = source;
23 _this.sourceIsBeingSubscribedTo = true;
24 return _this;
25 }
26 RepeatWhenSubscriber.prototype.notifyNext = function () {
27 this.sourceIsBeingSubscribedTo = true;
28 this.source.subscribe(this);
29 };
30 RepeatWhenSubscriber.prototype.notifyComplete = function () {
31 if (this.sourceIsBeingSubscribedTo === false) {
32 return _super.prototype.complete.call(this);
33 }
34 };
35 RepeatWhenSubscriber.prototype.complete = function () {
36 this.sourceIsBeingSubscribedTo = false;
37 if (!this.isStopped) {
38 if (!this.retries) {
39 this.subscribeToRetries();
40 }
41 if (!this.retriesSubscription || this.retriesSubscription.closed) {
42 return _super.prototype.complete.call(this);
43 }
44 this._unsubscribeAndRecycle();
45 this.notifications.next(undefined);
46 }
47 };
48 RepeatWhenSubscriber.prototype._unsubscribe = function () {
49 var _a = this, notifications = _a.notifications, retriesSubscription = _a.retriesSubscription;
50 if (notifications) {
51 notifications.unsubscribe();
52 this.notifications = undefined;
53 }
54 if (retriesSubscription) {
55 retriesSubscription.unsubscribe();
56 this.retriesSubscription = undefined;
57 }
58 this.retries = undefined;
59 };
60 RepeatWhenSubscriber.prototype._unsubscribeAndRecycle = function () {
61 var _unsubscribe = this._unsubscribe;
62 this._unsubscribe = null;
63 _super.prototype._unsubscribeAndRecycle.call(this);
64 this._unsubscribe = _unsubscribe;
65 return this;
66 };
67 RepeatWhenSubscriber.prototype.subscribeToRetries = function () {
68 this.notifications = new Subject();
69 var retries;
70 try {
71 var notifier = this.notifier;
72 retries = notifier(this.notifications);
73 }
74 catch (e) {
75 return _super.prototype.complete.call(this);
76 }
77 this.retries = retries;
78 this.retriesSubscription = innerSubscribe(retries, new SimpleInnerSubscriber(this));
79 };
80 return RepeatWhenSubscriber;
81}(SimpleOuterSubscriber));
82//# sourceMappingURL=repeatWhen.js.map
Note: See TracBrowser for help on using the repository browser.