1 /** PURE_IMPORTS_START tslib,_Subscriber,_scheduler_async PURE_IMPORTS_END */
2 import * as tslib_1 from "tslib";
3 import { Subscriber } from '../Subscriber';
4 import { async } from '../scheduler/async';
5 export function debounceTime(dueTime, scheduler) {
6 if (scheduler === void 0) {
9 return function (source) { return source.lift(new DebounceTimeOperator(dueTime, scheduler)); };
11 var DebounceTimeOperator = /*@__PURE__*/ (function () {
12 function DebounceTimeOperator(dueTime, scheduler) {
13 this.dueTime = dueTime;
14 this.scheduler = scheduler;
16 DebounceTimeOperator.prototype.call = function (subscriber, source) {
17 return source.subscribe(new DebounceTimeSubscriber(subscriber, this.dueTime, this.scheduler));
19 return DebounceTimeOperator;
21 var 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;
32 DebounceTimeSubscriber.prototype._next = function (value) {
34 this.lastValue = value;
36 this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext, this.dueTime, this));
38 DebounceTimeSubscriber.prototype._complete = function () {
40 this.destination.complete();
42 DebounceTimeSubscriber.prototype.debouncedNext = function () {
45 var lastValue = this.lastValue;
46 this.lastValue = null;
47 this.hasValue = false;
48 this.destination.next(lastValue);
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;
59 return DebounceTimeSubscriber;
61 function dispatchNext(subscriber) {
62 subscriber.debouncedNext();
64 //# sourceMappingURL=debounceTime.js.map