bigint-crypto-utils/node_modules/rxjs/_esm5/internal/operators/sample.js

46 lines
1.7 KiB
JavaScript
Raw Normal View History

/** PURE_IMPORTS_START tslib,_OuterSubscriber,_util_subscribeToResult PURE_IMPORTS_END */
import * as tslib_1 from "tslib";
import { OuterSubscriber } from '../OuterSubscriber';
import { subscribeToResult } from '../util/subscribeToResult';
export function sample(notifier) {
return function (source) { return source.lift(new SampleOperator(notifier)); };
}
var SampleOperator = /*@__PURE__*/ (function () {
function SampleOperator(notifier) {
this.notifier = notifier;
}
SampleOperator.prototype.call = function (subscriber, source) {
var sampleSubscriber = new SampleSubscriber(subscriber);
var subscription = source.subscribe(sampleSubscriber);
subscription.add(subscribeToResult(sampleSubscriber, this.notifier));
return subscription;
};
return SampleOperator;
}());
var SampleSubscriber = /*@__PURE__*/ (function (_super) {
tslib_1.__extends(SampleSubscriber, _super);
function SampleSubscriber() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.hasValue = false;
return _this;
}
SampleSubscriber.prototype._next = function (value) {
this.value = value;
this.hasValue = true;
};
SampleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
this.emitValue();
};
SampleSubscriber.prototype.notifyComplete = function () {
this.emitValue();
};
SampleSubscriber.prototype.emitValue = function () {
if (this.hasValue) {
this.hasValue = false;
this.destination.next(this.value);
}
};
return SampleSubscriber;
}(OuterSubscriber));
//# sourceMappingURL=sample.js.map