sample.js 1019 B

123456789101112131415161718192021222324252627
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.sample = void 0;
  4. var innerFrom_1 = require("../observable/innerFrom");
  5. var lift_1 = require("../util/lift");
  6. var noop_1 = require("../util/noop");
  7. var OperatorSubscriber_1 = require("./OperatorSubscriber");
  8. function sample(notifier) {
  9. return lift_1.operate(function (source, subscriber) {
  10. var hasValue = false;
  11. var lastValue = null;
  12. source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function (value) {
  13. hasValue = true;
  14. lastValue = value;
  15. }));
  16. innerFrom_1.innerFrom(notifier).subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function () {
  17. if (hasValue) {
  18. hasValue = false;
  19. var value = lastValue;
  20. lastValue = null;
  21. subscriber.next(value);
  22. }
  23. }, noop_1.noop));
  24. });
  25. }
  26. exports.sample = sample;
  27. //# sourceMappingURL=sample.js.map