wishthis/node_modules/rxjs/dist/esm5/internal/operators/sample.js

23 lines
836 B
JavaScript
Raw Normal View History

2023-02-08 12:35:10 +00:00
import { innerFrom } from '../observable/innerFrom';
2022-06-08 10:36:39 +00:00
import { operate } from '../util/lift';
import { noop } from '../util/noop';
import { createOperatorSubscriber } from './OperatorSubscriber';
export function sample(notifier) {
return operate(function (source, subscriber) {
var hasValue = false;
var lastValue = null;
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
hasValue = true;
lastValue = value;
}));
2023-02-08 12:35:10 +00:00
innerFrom(notifier).subscribe(createOperatorSubscriber(subscriber, function () {
2022-06-08 10:36:39 +00:00
if (hasValue) {
hasValue = false;
var value = lastValue;
lastValue = null;
subscriber.next(value);
}
}, noop));
});
}
//# sourceMappingURL=sample.js.map