source: trip-planner-front/node_modules/rxjs/_esm5/internal/operators/sampleTime.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: 1.8 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 sampleTime(period, scheduler) {
6 if (scheduler === void 0) {
7 scheduler = async;
8 }
9 return function (source) { return source.lift(new SampleTimeOperator(period, scheduler)); };
10}
11var 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}());
21var 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));
43function dispatchNotification(state) {
44 var subscriber = state.subscriber, period = state.period;
45 subscriber.notifyNext();
46 this.schedule(state, period);
47}
48//# sourceMappingURL=sampleTime.js.map
Note: See TracBrowser for help on using the repository browser.