30 lines
1011 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Observable_1 = require("../Observable");
var Subscription_1 = require("../Subscription");
var subscribeToArray_1 = require("../util/subscribeToArray");
function fromArray(input, scheduler) {
if (!scheduler) {
return new Observable_1.Observable(subscribeToArray_1.subscribeToArray(input));
}
else {
return new Observable_1.Observable(function (subscriber) {
var sub = new Subscription_1.Subscription();
var i = 0;
sub.add(scheduler.schedule(function () {
if (i === input.length) {
subscriber.complete();
return;
}
subscriber.next(input[i++]);
if (!subscriber.closed) {
sub.add(this.schedule());
}
}));
return sub;
});
}
}
exports.fromArray = fromArray;
//# sourceMappingURL=fromArray.js.map