source: trip-planner-front/node_modules/rxjs/internal/operators/timeoutWith.js@ bdd6491

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

initial commit

  • Property mode set to 100644
File size: 3.3 KB
Line 
1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7 return extendStatics(d, b);
8 }
9 return function (d, b) {
10 extendStatics(d, b);
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13 };
14})();
15Object.defineProperty(exports, "__esModule", { value: true });
16var async_1 = require("../scheduler/async");
17var isDate_1 = require("../util/isDate");
18var innerSubscribe_1 = require("../innerSubscribe");
19function timeoutWith(due, withObservable, scheduler) {
20 if (scheduler === void 0) { scheduler = async_1.async; }
21 return function (source) {
22 var absoluteTimeout = isDate_1.isDate(due);
23 var waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(due);
24 return source.lift(new TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler));
25 };
26}
27exports.timeoutWith = timeoutWith;
28var TimeoutWithOperator = (function () {
29 function TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler) {
30 this.waitFor = waitFor;
31 this.absoluteTimeout = absoluteTimeout;
32 this.withObservable = withObservable;
33 this.scheduler = scheduler;
34 }
35 TimeoutWithOperator.prototype.call = function (subscriber, source) {
36 return source.subscribe(new TimeoutWithSubscriber(subscriber, this.absoluteTimeout, this.waitFor, this.withObservable, this.scheduler));
37 };
38 return TimeoutWithOperator;
39}());
40var TimeoutWithSubscriber = (function (_super) {
41 __extends(TimeoutWithSubscriber, _super);
42 function TimeoutWithSubscriber(destination, absoluteTimeout, waitFor, withObservable, scheduler) {
43 var _this = _super.call(this, destination) || this;
44 _this.absoluteTimeout = absoluteTimeout;
45 _this.waitFor = waitFor;
46 _this.withObservable = withObservable;
47 _this.scheduler = scheduler;
48 _this.scheduleTimeout();
49 return _this;
50 }
51 TimeoutWithSubscriber.dispatchTimeout = function (subscriber) {
52 var withObservable = subscriber.withObservable;
53 subscriber._unsubscribeAndRecycle();
54 subscriber.add(innerSubscribe_1.innerSubscribe(withObservable, new innerSubscribe_1.SimpleInnerSubscriber(subscriber)));
55 };
56 TimeoutWithSubscriber.prototype.scheduleTimeout = function () {
57 var action = this.action;
58 if (action) {
59 this.action = action.schedule(this, this.waitFor);
60 }
61 else {
62 this.add(this.action = this.scheduler.schedule(TimeoutWithSubscriber.dispatchTimeout, this.waitFor, this));
63 }
64 };
65 TimeoutWithSubscriber.prototype._next = function (value) {
66 if (!this.absoluteTimeout) {
67 this.scheduleTimeout();
68 }
69 _super.prototype._next.call(this, value);
70 };
71 TimeoutWithSubscriber.prototype._unsubscribe = function () {
72 this.action = undefined;
73 this.scheduler = null;
74 this.withObservable = null;
75 };
76 return TimeoutWithSubscriber;
77}(innerSubscribe_1.SimpleOuterSubscriber));
78//# sourceMappingURL=timeoutWith.js.map
Note: See TracBrowser for help on using the repository browser.