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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /** PURE_IMPORTS_START _Observable,_Subscription,_symbol_iterator PURE_IMPORTS_END */
  2. import { Observable } from '../Observable';
  3. import { Subscription } from '../Subscription';
  4. import { iterator as Symbol_iterator } from '../symbol/iterator';
  5. export function scheduleIterable(input, scheduler) {
  6. if (!input) {
  7. throw new Error('Iterable cannot be null');
  8. }
  9. return new Observable(function (subscriber) {
  10. var sub = new Subscription();
  11. var iterator;
  12. sub.add(function () {
  13. if (iterator && typeof iterator.return === 'function') {
  14. iterator.return();
  15. }
  16. });
  17. sub.add(scheduler.schedule(function () {
  18. iterator = input[Symbol_iterator]();
  19. sub.add(scheduler.schedule(function () {
  20. if (subscriber.closed) {
  21. return;
  22. }
  23. var value;
  24. var done;
  25. try {
  26. var result = iterator.next();
  27. value = result.value;
  28. done = result.done;
  29. }
  30. catch (err) {
  31. subscriber.error(err);
  32. return;
  33. }
  34. if (done) {
  35. subscriber.complete();
  36. }
  37. else {
  38. subscriber.next(value);
  39. this.schedule();
  40. }
  41. }));
  42. }));
  43. return sub;
  44. });
  45. }
  46. //# sourceMappingURL=scheduleIterable.js.map