source: trip-planner-front/node_modules/rxjs/_esm2015/internal/scheduled/scheduleIterable.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.4 KB
Line 
1import { Observable } from '../Observable';
2import { Subscription } from '../Subscription';
3import { iterator as Symbol_iterator } from '../symbol/iterator';
4export function scheduleIterable(input, scheduler) {
5 if (!input) {
6 throw new Error('Iterable cannot be null');
7 }
8 return new Observable(subscriber => {
9 const sub = new Subscription();
10 let iterator;
11 sub.add(() => {
12 if (iterator && typeof iterator.return === 'function') {
13 iterator.return();
14 }
15 });
16 sub.add(scheduler.schedule(() => {
17 iterator = input[Symbol_iterator]();
18 sub.add(scheduler.schedule(function () {
19 if (subscriber.closed) {
20 return;
21 }
22 let value;
23 let done;
24 try {
25 const result = iterator.next();
26 value = result.value;
27 done = result.done;
28 }
29 catch (err) {
30 subscriber.error(err);
31 return;
32 }
33 if (done) {
34 subscriber.complete();
35 }
36 else {
37 subscriber.next(value);
38 this.schedule();
39 }
40 }));
41 }));
42 return sub;
43 });
44}
45//# sourceMappingURL=scheduleIterable.js.map
Note: See TracBrowser for help on using the repository browser.