travel/admin/node_modules/rxjs/_esm5/internal/scheduled/scheduleIterable.js

47 lines
1.5 KiB
JavaScript

/** PURE_IMPORTS_START _Observable,_Subscription,_symbol_iterator PURE_IMPORTS_END */
import { Observable } from '../Observable';
import { Subscription } from '../Subscription';
import { iterator as Symbol_iterator } from '../symbol/iterator';
export function scheduleIterable(input, scheduler) {
if (!input) {
throw new Error('Iterable cannot be null');
}
return new Observable(function (subscriber) {
var sub = new Subscription();
var iterator;
sub.add(function () {
if (iterator && typeof iterator.return === 'function') {
iterator.return();
}
});
sub.add(scheduler.schedule(function () {
iterator = input[Symbol_iterator]();
sub.add(scheduler.schedule(function () {
if (subscriber.closed) {
return;
}
var value;
var done;
try {
var result = iterator.next();
value = result.value;
done = result.done;
}
catch (err) {
subscriber.error(err);
return;
}
if (done) {
subscriber.complete();
}
else {
subscriber.next(value);
this.schedule();
}
}));
}));
return sub;
});
}
//# sourceMappingURL=scheduleIterable.js.map