Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sample.js 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 OuterSubscriber_1 = require("../OuterSubscriber");
  17. var subscribeToResult_1 = require("../util/subscribeToResult");
  18. function sample(notifier) {
  19. return function (source) { return source.lift(new SampleOperator(notifier)); };
  20. }
  21. exports.sample = sample;
  22. var SampleOperator = (function () {
  23. function SampleOperator(notifier) {
  24. this.notifier = notifier;
  25. }
  26. SampleOperator.prototype.call = function (subscriber, source) {
  27. var sampleSubscriber = new SampleSubscriber(subscriber);
  28. var subscription = source.subscribe(sampleSubscriber);
  29. subscription.add(subscribeToResult_1.subscribeToResult(sampleSubscriber, this.notifier));
  30. return subscription;
  31. };
  32. return SampleOperator;
  33. }());
  34. var SampleSubscriber = (function (_super) {
  35. __extends(SampleSubscriber, _super);
  36. function SampleSubscriber() {
  37. var _this = _super !== null && _super.apply(this, arguments) || this;
  38. _this.hasValue = false;
  39. return _this;
  40. }
  41. SampleSubscriber.prototype._next = function (value) {
  42. this.value = value;
  43. this.hasValue = true;
  44. };
  45. SampleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  46. this.emitValue();
  47. };
  48. SampleSubscriber.prototype.notifyComplete = function () {
  49. this.emitValue();
  50. };
  51. SampleSubscriber.prototype.emitValue = function () {
  52. if (this.hasValue) {
  53. this.hasValue = false;
  54. this.destination.next(this.value);
  55. }
  56. };
  57. return SampleSubscriber;
  58. }(OuterSubscriber_1.OuterSubscriber));
  59. //# sourceMappingURL=sample.js.map