wishthis/node_modules/rxjs/dist/cjs/internal/operators/sample.js
2023-02-08 13:35:10 +01:00

27 lines
No EOL
1,019 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sample = void 0;
var innerFrom_1 = require("../observable/innerFrom");
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(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function (value) {
hasValue = true;
lastValue = value;
}));
innerFrom_1.innerFrom(notifier).subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function () {
if (hasValue) {
hasValue = false;
var value = lastValue;
lastValue = null;
subscriber.next(value);
}
}, noop_1.noop));
});
}
exports.sample = sample;
//# sourceMappingURL=sample.js.map