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) {
9 return function (source) { return source.lift(new SampleTimeOperator(period, scheduler)); };
11 var SampleTimeOperator = /*@__PURE__*/ (function () {
12 function SampleTimeOperator(period, scheduler) {
14 this.scheduler = scheduler;
16 SampleTimeOperator.prototype.call = function (subscriber, source) {
17 return source.subscribe(new SampleTimeSubscriber(subscriber, this.period, this.scheduler));
19 return SampleTimeOperator;
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 }));
31 SampleTimeSubscriber.prototype._next = function (value) {
32 this.lastValue = value;
35 SampleTimeSubscriber.prototype.notifyNext = function () {
37 this.hasValue = false;
38 this.destination.next(this.lastValue);
41 return SampleTimeSubscriber;
43 function dispatchNotification(state) {
44 var subscriber = state.subscriber, period = state.period;
45 subscriber.notifyNext();
46 this.schedule(state, period);
48 //# sourceMappingURL=sampleTime.js.map