"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sample = void 0;
const Observable_js_1 = require("../Observable.js");
const noop_js_1 = require("../util/noop.js");
function sample(notifier) {
    return (source) => new Observable_js_1.Observable((destination) => {
        let hasValue = false;
        let lastValue = null;
        source.subscribe((0, Observable_js_1.operate)({
            destination,
            next: (value) => {
                hasValue = true;
                lastValue = value;
            },
        }));
        (0, Observable_js_1.from)(notifier).subscribe((0, Observable_js_1.operate)({
            destination,
            next: () => {
                if (hasValue) {
                    hasValue = false;
                    const value = lastValue;
                    lastValue = null;
                    destination.next(value);
                }
            },
            complete: noop_js_1.noop,
        }));
    });
}
exports.sample = sample;//# sourceMappingURL=http://go/sourcemap/sourcemaps/fc2563ec93d793fc275eef734405a4fdf8b47b20/node_modules/rxjs/dist/cjs/internal/operators/sample.js.map