Every new change
This commit is contained in:
39
node_modules/rxjs/_esm2015/internal/operators/sample.js
generated
vendored
Normal file
39
node_modules/rxjs/_esm2015/internal/operators/sample.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
import { OuterSubscriber } from '../OuterSubscriber';
|
||||
import { subscribeToResult } from '../util/subscribeToResult';
|
||||
export function sample(notifier) {
|
||||
return (source) => source.lift(new SampleOperator(notifier));
|
||||
}
|
||||
class SampleOperator {
|
||||
constructor(notifier) {
|
||||
this.notifier = notifier;
|
||||
}
|
||||
call(subscriber, source) {
|
||||
const sampleSubscriber = new SampleSubscriber(subscriber);
|
||||
const subscription = source.subscribe(sampleSubscriber);
|
||||
subscription.add(subscribeToResult(sampleSubscriber, this.notifier));
|
||||
return subscription;
|
||||
}
|
||||
}
|
||||
class SampleSubscriber extends OuterSubscriber {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.hasValue = false;
|
||||
}
|
||||
_next(value) {
|
||||
this.value = value;
|
||||
this.hasValue = true;
|
||||
}
|
||||
notifyNext(outerValue, innerValue, outerIndex, innerIndex, innerSub) {
|
||||
this.emitValue();
|
||||
}
|
||||
notifyComplete() {
|
||||
this.emitValue();
|
||||
}
|
||||
emitValue() {
|
||||
if (this.hasValue) {
|
||||
this.hasValue = false;
|
||||
this.destination.next(this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=sample.js.map
|
Reference in New Issue
Block a user