source: trip-planner-front/node_modules/rxjs/_esm2015/internal/operators/sampleTime.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1import { Subscriber } from '../Subscriber';
2import { async } from '../scheduler/async';
3export function sampleTime(period, scheduler = async) {
4 return (source) => source.lift(new SampleTimeOperator(period, scheduler));
5}
6class SampleTimeOperator {
7 constructor(period, scheduler) {
8 this.period = period;
9 this.scheduler = scheduler;
10 }
11 call(subscriber, source) {
12 return source.subscribe(new SampleTimeSubscriber(subscriber, this.period, this.scheduler));
13 }
14}
15class SampleTimeSubscriber extends Subscriber {
16 constructor(destination, period, scheduler) {
17 super(destination);
18 this.period = period;
19 this.scheduler = scheduler;
20 this.hasValue = false;
21 this.add(scheduler.schedule(dispatchNotification, period, { subscriber: this, period }));
22 }
23 _next(value) {
24 this.lastValue = value;
25 this.hasValue = true;
26 }
27 notifyNext() {
28 if (this.hasValue) {
29 this.hasValue = false;
30 this.destination.next(this.lastValue);
31 }
32 }
33}
34function dispatchNotification(state) {
35 let { subscriber, period } = state;
36 subscriber.notifyNext();
37 this.schedule(state, period);
38}
39//# sourceMappingURL=sampleTime.js.map
Note: See TracBrowser for help on using the repository browser.