Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | /** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */
|
---|
2 | import * as tslib_1 from "tslib";
|
---|
3 | import { Subscriber } from '../Subscriber';
|
---|
4 | export function retry(count) {
|
---|
5 | if (count === void 0) {
|
---|
6 | count = -1;
|
---|
7 | }
|
---|
8 | return function (source) { return source.lift(new RetryOperator(count, source)); };
|
---|
9 | }
|
---|
10 | var RetryOperator = /*@__PURE__*/ (function () {
|
---|
11 | function RetryOperator(count, source) {
|
---|
12 | this.count = count;
|
---|
13 | this.source = source;
|
---|
14 | }
|
---|
15 | RetryOperator.prototype.call = function (subscriber, source) {
|
---|
16 | return source.subscribe(new RetrySubscriber(subscriber, this.count, this.source));
|
---|
17 | };
|
---|
18 | return RetryOperator;
|
---|
19 | }());
|
---|
20 | var RetrySubscriber = /*@__PURE__*/ (function (_super) {
|
---|
21 | tslib_1.__extends(RetrySubscriber, _super);
|
---|
22 | function RetrySubscriber(destination, count, source) {
|
---|
23 | var _this = _super.call(this, destination) || this;
|
---|
24 | _this.count = count;
|
---|
25 | _this.source = source;
|
---|
26 | return _this;
|
---|
27 | }
|
---|
28 | RetrySubscriber.prototype.error = function (err) {
|
---|
29 | if (!this.isStopped) {
|
---|
30 | var _a = this, source = _a.source, count = _a.count;
|
---|
31 | if (count === 0) {
|
---|
32 | return _super.prototype.error.call(this, err);
|
---|
33 | }
|
---|
34 | else if (count > -1) {
|
---|
35 | this.count = count - 1;
|
---|
36 | }
|
---|
37 | source.subscribe(this._unsubscribeAndRecycle());
|
---|
38 | }
|
---|
39 | };
|
---|
40 | return RetrySubscriber;
|
---|
41 | }(Subscriber));
|
---|
42 | //# sourceMappingURL=retry.js.map
|
---|
Note:
See
TracBrowser
for help on using the repository browser.