Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / _esm2015 / internal / operators / sample.js
1 import { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';
2 export function sample(notifier) {
3     return (source) => source.lift(new SampleOperator(notifier));
4 }
5 class SampleOperator {
6     constructor(notifier) {
7         this.notifier = notifier;
8     }
9     call(subscriber, source) {
10         const sampleSubscriber = new SampleSubscriber(subscriber);
11         const subscription = source.subscribe(sampleSubscriber);
12         subscription.add(innerSubscribe(this.notifier, new SimpleInnerSubscriber(sampleSubscriber)));
13         return subscription;
14     }
15 }
16 class SampleSubscriber extends SimpleOuterSubscriber {
17     constructor() {
18         super(...arguments);
19         this.hasValue = false;
20     }
21     _next(value) {
22         this.value = value;
23         this.hasValue = true;
24     }
25     notifyNext() {
26         this.emitValue();
27     }
28     notifyComplete() {
29         this.emitValue();
30     }
31     emitValue() {
32         if (this.hasValue) {
33             this.hasValue = false;
34             this.destination.next(this.value);
35         }
36     }
37 }
38 //# sourceMappingURL=sample.js.map