@reactivex/rxjs
Version:
Reactive Extensions for modern JavaScript
57 lines • 1.79 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var concat_1 = require("../observable/concat");
var isScheduler_1 = require("../util/isScheduler");
/* tslint:enable:max-line-length */
/**
* Returns an Observable that emits the items you specify as arguments before it begins to emit
* items emitted by the source Observable.
*
* <span class="informal">First emits its arguments in order, and then any
* emissions from the source.</span>
*
* 
*
* ## Examples
*
* Start the chain of emissions with `"first"`, `"second"`
*
* ```ts
* import { of } from 'rxjs';
* import { startWith } from 'rxjs/operators';
*
* of("from source")
* .pipe(startWith("first", "second"))
* .subscribe(x => console.log(x));
*
* // results:
* // "first"
* // "second"
* // "from source"
* ```
*
* @param {...T} values - Items you want the modified Observable to emit first.
* @param {SchedulerLike} [scheduler] - A {@link SchedulerLike} to use for scheduling
* the emissions of the `next` notifications.
* @return {Observable} An Observable that emits the items in the specified Iterable and then emits the items
* emitted by the source Observable.
* @method startWith
* @owner Observable
*/
function startWith() {
var array = [];
for (var _i = 0; _i < arguments.length; _i++) {
array[_i] = arguments[_i];
}
var scheduler = array[array.length - 1];
if (isScheduler_1.isScheduler(scheduler)) {
// deprecated path
array.pop();
return function (source) { return concat_1.concat(array, source, scheduler); };
}
else {
return function (source) { return concat_1.concat(array, source); };
}
}
exports.startWith = startWith;
//# sourceMappingURL=startWith.js.map