scheduleIterable.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.scheduleIterable = void 0;
  4. var Observable_1 = require("../Observable");
  5. var iterator_1 = require("../symbol/iterator");
  6. var isFunction_1 = require("../util/isFunction");
  7. var executeSchedule_1 = require("../util/executeSchedule");
  8. function scheduleIterable(input, scheduler) {
  9. return new Observable_1.Observable(function (subscriber) {
  10. var iterator;
  11. executeSchedule_1.executeSchedule(subscriber, scheduler, function () {
  12. iterator = input[iterator_1.iterator]();
  13. executeSchedule_1.executeSchedule(subscriber, scheduler, function () {
  14. var _a;
  15. var value;
  16. var done;
  17. try {
  18. (_a = iterator.next(), value = _a.value, done = _a.done);
  19. }
  20. catch (err) {
  21. subscriber.error(err);
  22. return;
  23. }
  24. if (done) {
  25. subscriber.complete();
  26. }
  27. else {
  28. subscriber.next(value);
  29. }
  30. }, 0, true);
  31. });
  32. return function () { return isFunction_1.isFunction(iterator === null || iterator === void 0 ? void 0 : iterator.return) && iterator.return(); };
  33. });
  34. }
  35. exports.scheduleIterable = scheduleIterable;
  36. //# sourceMappingURL=scheduleIterable.js.map