Last change
on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.5 KB
|
Line | |
---|
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 |
---|
Note:
See
TracBrowser
for help on using the repository browser.