[6a3a178] | 1 | /** PURE_IMPORTS_START tslib,_scheduler_async,_util_isDate,_innerSubscribe PURE_IMPORTS_END */
|
---|
| 2 | import * as tslib_1 from "tslib";
|
---|
| 3 | import { async } from '../scheduler/async';
|
---|
| 4 | import { isDate } from '../util/isDate';
|
---|
| 5 | import { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';
|
---|
| 6 | export function timeoutWith(due, withObservable, scheduler) {
|
---|
| 7 | if (scheduler === void 0) {
|
---|
| 8 | scheduler = async;
|
---|
| 9 | }
|
---|
| 10 | return function (source) {
|
---|
| 11 | var absoluteTimeout = isDate(due);
|
---|
| 12 | var waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(due);
|
---|
| 13 | return source.lift(new TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler));
|
---|
| 14 | };
|
---|
| 15 | }
|
---|
| 16 | var TimeoutWithOperator = /*@__PURE__*/ (function () {
|
---|
| 17 | function TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler) {
|
---|
| 18 | this.waitFor = waitFor;
|
---|
| 19 | this.absoluteTimeout = absoluteTimeout;
|
---|
| 20 | this.withObservable = withObservable;
|
---|
| 21 | this.scheduler = scheduler;
|
---|
| 22 | }
|
---|
| 23 | TimeoutWithOperator.prototype.call = function (subscriber, source) {
|
---|
| 24 | return source.subscribe(new TimeoutWithSubscriber(subscriber, this.absoluteTimeout, this.waitFor, this.withObservable, this.scheduler));
|
---|
| 25 | };
|
---|
| 26 | return TimeoutWithOperator;
|
---|
| 27 | }());
|
---|
| 28 | var TimeoutWithSubscriber = /*@__PURE__*/ (function (_super) {
|
---|
| 29 | tslib_1.__extends(TimeoutWithSubscriber, _super);
|
---|
| 30 | function TimeoutWithSubscriber(destination, absoluteTimeout, waitFor, withObservable, scheduler) {
|
---|
| 31 | var _this = _super.call(this, destination) || this;
|
---|
| 32 | _this.absoluteTimeout = absoluteTimeout;
|
---|
| 33 | _this.waitFor = waitFor;
|
---|
| 34 | _this.withObservable = withObservable;
|
---|
| 35 | _this.scheduler = scheduler;
|
---|
| 36 | _this.scheduleTimeout();
|
---|
| 37 | return _this;
|
---|
| 38 | }
|
---|
| 39 | TimeoutWithSubscriber.dispatchTimeout = function (subscriber) {
|
---|
| 40 | var withObservable = subscriber.withObservable;
|
---|
| 41 | subscriber._unsubscribeAndRecycle();
|
---|
| 42 | subscriber.add(innerSubscribe(withObservable, new SimpleInnerSubscriber(subscriber)));
|
---|
| 43 | };
|
---|
| 44 | TimeoutWithSubscriber.prototype.scheduleTimeout = function () {
|
---|
| 45 | var action = this.action;
|
---|
| 46 | if (action) {
|
---|
| 47 | this.action = action.schedule(this, this.waitFor);
|
---|
| 48 | }
|
---|
| 49 | else {
|
---|
| 50 | this.add(this.action = this.scheduler.schedule(TimeoutWithSubscriber.dispatchTimeout, this.waitFor, this));
|
---|
| 51 | }
|
---|
| 52 | };
|
---|
| 53 | TimeoutWithSubscriber.prototype._next = function (value) {
|
---|
| 54 | if (!this.absoluteTimeout) {
|
---|
| 55 | this.scheduleTimeout();
|
---|
| 56 | }
|
---|
| 57 | _super.prototype._next.call(this, value);
|
---|
| 58 | };
|
---|
| 59 | TimeoutWithSubscriber.prototype._unsubscribe = function () {
|
---|
| 60 | this.action = undefined;
|
---|
| 61 | this.scheduler = null;
|
---|
| 62 | this.withObservable = null;
|
---|
| 63 | };
|
---|
| 64 | return TimeoutWithSubscriber;
|
---|
| 65 | }(SimpleOuterSubscriber));
|
---|
| 66 | //# sourceMappingURL=timeoutWith.js.map
|
---|