source: trip-planner-front/node_modules/rxjs/_esm5/internal/operators/debounceTime.js

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: 2.4 KB
Line 
1/** PURE_IMPORTS_START tslib,_Subscriber,_scheduler_async PURE_IMPORTS_END */
2import * as tslib_1 from "tslib";
3import { Subscriber } from '../Subscriber';
4import { async } from '../scheduler/async';
5export function debounceTime(dueTime, scheduler) {
6 if (scheduler === void 0) {
7 scheduler = async;
8 }
9 return function (source) { return source.lift(new DebounceTimeOperator(dueTime, scheduler)); };
10}
11var DebounceTimeOperator = /*@__PURE__*/ (function () {
12 function DebounceTimeOperator(dueTime, scheduler) {
13 this.dueTime = dueTime;
14 this.scheduler = scheduler;
15 }
16 DebounceTimeOperator.prototype.call = function (subscriber, source) {
17 return source.subscribe(new DebounceTimeSubscriber(subscriber, this.dueTime, this.scheduler));
18 };
19 return DebounceTimeOperator;
20}());
21var DebounceTimeSubscriber = /*@__PURE__*/ (function (_super) {
22 tslib_1.__extends(DebounceTimeSubscriber, _super);
23 function DebounceTimeSubscriber(destination, dueTime, scheduler) {
24 var _this = _super.call(this, destination) || this;
25 _this.dueTime = dueTime;
26 _this.scheduler = scheduler;
27 _this.debouncedSubscription = null;
28 _this.lastValue = null;
29 _this.hasValue = false;
30 return _this;
31 }
32 DebounceTimeSubscriber.prototype._next = function (value) {
33 this.clearDebounce();
34 this.lastValue = value;
35 this.hasValue = true;
36 this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext, this.dueTime, this));
37 };
38 DebounceTimeSubscriber.prototype._complete = function () {
39 this.debouncedNext();
40 this.destination.complete();
41 };
42 DebounceTimeSubscriber.prototype.debouncedNext = function () {
43 this.clearDebounce();
44 if (this.hasValue) {
45 var lastValue = this.lastValue;
46 this.lastValue = null;
47 this.hasValue = false;
48 this.destination.next(lastValue);
49 }
50 };
51 DebounceTimeSubscriber.prototype.clearDebounce = function () {
52 var debouncedSubscription = this.debouncedSubscription;
53 if (debouncedSubscription !== null) {
54 this.remove(debouncedSubscription);
55 debouncedSubscription.unsubscribe();
56 this.debouncedSubscription = null;
57 }
58 };
59 return DebounceTimeSubscriber;
60}(Subscriber));
61function dispatchNext(subscriber) {
62 subscriber.debouncedNext();
63}
64//# sourceMappingURL=debounceTime.js.map
Note: See TracBrowser for help on using the repository browser.