Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / _esm5 / internal / operators / sampleTime.js
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 sampleTime(period, scheduler) {
6     if (scheduler === void 0) {
7         scheduler = async;
8     }
9     return function (source) { return source.lift(new SampleTimeOperator(period, scheduler)); };
10 }
11 var SampleTimeOperator = /*@__PURE__*/ (function () {
12     function SampleTimeOperator(period, scheduler) {
13         this.period = period;
14         this.scheduler = scheduler;
15     }
16     SampleTimeOperator.prototype.call = function (subscriber, source) {
17         return source.subscribe(new SampleTimeSubscriber(subscriber, this.period, this.scheduler));
18     };
19     return SampleTimeOperator;
20 }());
21 var SampleTimeSubscriber = /*@__PURE__*/ (function (_super) {
22     tslib_1.__extends(SampleTimeSubscriber, _super);
23     function SampleTimeSubscriber(destination, period, scheduler) {
24         var _this = _super.call(this, destination) || this;
25         _this.period = period;
26         _this.scheduler = scheduler;
27         _this.hasValue = false;
28         _this.add(scheduler.schedule(dispatchNotification, period, { subscriber: _this, period: period }));
29         return _this;
30     }
31     SampleTimeSubscriber.prototype._next = function (value) {
32         this.lastValue = value;
33         this.hasValue = true;
34     };
35     SampleTimeSubscriber.prototype.notifyNext = function () {
36         if (this.hasValue) {
37             this.hasValue = false;
38             this.destination.next(this.lastValue);
39         }
40     };
41     return SampleTimeSubscriber;
42 }(Subscriber));
43 function dispatchNotification(state) {
44     var subscriber = state.subscriber, period = state.period;
45     subscriber.notifyNext();
46     this.schedule(state, period);
47 }
48 //# sourceMappingURL=sampleTime.js.map