Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

sample.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /** PURE_IMPORTS_START tslib,_innerSubscribe PURE_IMPORTS_END */
  2. import * as tslib_1 from "tslib";
  3. import { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';
  4. export function sample(notifier) {
  5. return function (source) { return source.lift(new SampleOperator(notifier)); };
  6. }
  7. var SampleOperator = /*@__PURE__*/ (function () {
  8. function SampleOperator(notifier) {
  9. this.notifier = notifier;
  10. }
  11. SampleOperator.prototype.call = function (subscriber, source) {
  12. var sampleSubscriber = new SampleSubscriber(subscriber);
  13. var subscription = source.subscribe(sampleSubscriber);
  14. subscription.add(innerSubscribe(this.notifier, new SimpleInnerSubscriber(sampleSubscriber)));
  15. return subscription;
  16. };
  17. return SampleOperator;
  18. }());
  19. var SampleSubscriber = /*@__PURE__*/ (function (_super) {
  20. tslib_1.__extends(SampleSubscriber, _super);
  21. function SampleSubscriber() {
  22. var _this = _super !== null && _super.apply(this, arguments) || this;
  23. _this.hasValue = false;
  24. return _this;
  25. }
  26. SampleSubscriber.prototype._next = function (value) {
  27. this.value = value;
  28. this.hasValue = true;
  29. };
  30. SampleSubscriber.prototype.notifyNext = function () {
  31. this.emitValue();
  32. };
  33. SampleSubscriber.prototype.notifyComplete = function () {
  34. this.emitValue();
  35. };
  36. SampleSubscriber.prototype.emitValue = function () {
  37. if (this.hasValue) {
  38. this.hasValue = false;
  39. this.destination.next(this.value);
  40. }
  41. };
  42. return SampleSubscriber;
  43. }(SimpleOuterSubscriber));
  44. //# sourceMappingURL=sample.js.map