rxjs
Version:
Reactive Extensions for modern JavaScript
27 lines • 963 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.sample = void 0;
var lift_1 = require("../util/lift");
var noop_1 = require("../util/noop");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
function sample(notifier) {
return lift_1.operate(function (source, subscriber) {
var hasValue = false;
var lastValue = null;
source.subscribe(new OperatorSubscriber_1.OperatorSubscriber(subscriber, function (value) {
hasValue = true;
lastValue = value;
}));
var emit = function () {
if (hasValue) {
hasValue = false;
var value = lastValue;
lastValue = null;
subscriber.next(value);
}
};
notifier.subscribe(new OperatorSubscriber_1.OperatorSubscriber(subscriber, emit, noop_1.noop));
});
}
exports.sample = sample;
//# sourceMappingURL=sample.js.map
;