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 1.7KB

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