1 import { Subscriber } from '../Subscriber';
2 import { async } from '../scheduler/async';
3 export function sampleTime(period, scheduler = async) {
4 return (source) => source.lift(new SampleTimeOperator(period, scheduler));
6 class SampleTimeOperator {
7 constructor(period, scheduler) {
9 this.scheduler = scheduler;
11 call(subscriber, source) {
12 return source.subscribe(new SampleTimeSubscriber(subscriber, this.period, this.scheduler));
15 class SampleTimeSubscriber extends Subscriber {
16 constructor(destination, period, scheduler) {
19 this.scheduler = scheduler;
20 this.hasValue = false;
21 this.add(scheduler.schedule(dispatchNotification, period, { subscriber: this, period }));
24 this.lastValue = value;
29 this.hasValue = false;
30 this.destination.next(this.lastValue);
34 function dispatchNotification(state) {
35 let { subscriber, period } = state;
36 subscriber.notifyNext();
37 this.schedule(state, period);
39 //# sourceMappingURL=sampleTime.js.map