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

sample.js 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. }
  9. return function (d, b) {
  10. extendStatics(d, b);
  11. function __() { this.constructor = d; }
  12. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13. };
  14. })();
  15. Object.defineProperty(exports, "__esModule", { value: true });
  16. var innerSubscribe_1 = require("../innerSubscribe");
  17. function sample(notifier) {
  18. return function (source) { return source.lift(new SampleOperator(notifier)); };
  19. }
  20. exports.sample = sample;
  21. var SampleOperator = (function () {
  22. function SampleOperator(notifier) {
  23. this.notifier = notifier;
  24. }
  25. SampleOperator.prototype.call = function (subscriber, source) {
  26. var sampleSubscriber = new SampleSubscriber(subscriber);
  27. var subscription = source.subscribe(sampleSubscriber);
  28. subscription.add(innerSubscribe_1.innerSubscribe(this.notifier, new innerSubscribe_1.SimpleInnerSubscriber(sampleSubscriber)));
  29. return subscription;
  30. };
  31. return SampleOperator;
  32. }());
  33. var SampleSubscriber = (function (_super) {
  34. __extends(SampleSubscriber, _super);
  35. function SampleSubscriber() {
  36. var _this = _super !== null && _super.apply(this, arguments) || this;
  37. _this.hasValue = false;
  38. return _this;
  39. }
  40. SampleSubscriber.prototype._next = function (value) {
  41. this.value = value;
  42. this.hasValue = true;
  43. };
  44. SampleSubscriber.prototype.notifyNext = function () {
  45. this.emitValue();
  46. };
  47. SampleSubscriber.prototype.notifyComplete = function () {
  48. this.emitValue();
  49. };
  50. SampleSubscriber.prototype.emitValue = function () {
  51. if (this.hasValue) {
  52. this.hasValue = false;
  53. this.destination.next(this.value);
  54. }
  55. };
  56. return SampleSubscriber;
  57. }(innerSubscribe_1.SimpleOuterSubscriber));
  58. //# sourceMappingURL=sample.js.map