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.

scheduleIterable.js 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var Observable_1 = require("../Observable");
  4. var Subscription_1 = require("../Subscription");
  5. var iterator_1 = require("../symbol/iterator");
  6. function scheduleIterable(input, scheduler) {
  7. if (!input) {
  8. throw new Error('Iterable cannot be null');
  9. }
  10. return new Observable_1.Observable(function (subscriber) {
  11. var sub = new Subscription_1.Subscription();
  12. var iterator;
  13. sub.add(function () {
  14. if (iterator && typeof iterator.return === 'function') {
  15. iterator.return();
  16. }
  17. });
  18. sub.add(scheduler.schedule(function () {
  19. iterator = input[iterator_1.iterator]();
  20. sub.add(scheduler.schedule(function () {
  21. if (subscriber.closed) {
  22. return;
  23. }
  24. var value;
  25. var done;
  26. try {
  27. var result = iterator.next();
  28. value = result.value;
  29. done = result.done;
  30. }
  31. catch (err) {
  32. subscriber.error(err);
  33. return;
  34. }
  35. if (done) {
  36. subscriber.complete();
  37. }
  38. else {
  39. subscriber.next(value);
  40. this.schedule();
  41. }
  42. }));
  43. }));
  44. return sub;
  45. });
  46. }
  47. exports.scheduleIterable = scheduleIterable;
  48. //# sourceMappingURL=scheduleIterable.js.map