scheduleIterable.js 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. import { Observable } from '../Observable';
  2. import { iterator as Symbol_iterator } from '../symbol/iterator';
  3. import { isFunction } from '../util/isFunction';
  4. import { executeSchedule } from '../util/executeSchedule';
  5. export function scheduleIterable(input, scheduler) {
  6. return new Observable(function (subscriber) {
  7. var iterator;
  8. executeSchedule(subscriber, scheduler, function () {
  9. iterator = input[Symbol_iterator]();
  10. executeSchedule(subscriber, scheduler, function () {
  11. var _a;
  12. var value;
  13. var done;
  14. try {
  15. (_a = iterator.next(), value = _a.value, done = _a.done);
  16. }
  17. catch (err) {
  18. subscriber.error(err);
  19. return;
  20. }
  21. if (done) {
  22. subscriber.complete();
  23. }
  24. else {
  25. subscriber.next(value);
  26. }
  27. }, 0, true);
  28. });
  29. return function () { return isFunction(iterator === null || iterator === void 0 ? void 0 : iterator.return) && iterator.return(); };
  30. });
  31. }
  32. //# sourceMappingURL=scheduleIterable.js.map