UNPKG

@reactivex/rxjs

Version:

Reactive Extensions for modern JavaScript

76 lines 1.84 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var isScheduler_1 = require("../util/isScheduler"); var fromArray_1 = require("./fromArray"); var scheduleArray_1 = require("../scheduled/scheduleArray"); /* tslint:enable:max-line-length */ /** * Converts the arguments to an observable sequence. * * <span class="informal">Each argument becomes a `next` notification.</span> * * ![](of.png) * * Unlike {@link from}, it does not do any flattening and emits each argument in whole * as a separate `next` notification. * * ## Examples * * Emit the values `10, 20, 30` * * ```ts * import { of } from 'rxjs'; * * of(10, 20, 30) * .subscribe( * next => console.log('next:', next), * err => console.log('error:', err), * () => console.log('the end'), * ); * // result: * // 'next: 10' * // 'next: 20' * // 'next: 30' * * ``` * * Emit the array `[1,2,3]` * * ```ts * import { of } from 'rxjs'; * * of([1,2,3]) * .subscribe( * next => console.log('next:', next), * err => console.log('error:', err), * () => console.log('the end'), * ); * // result: * // 'next: [1,2,3]' * ``` * * @see {@link from} * @see {@link range} * * @param {...T} values A comma separated list of arguments you want to be emitted * @return {Observable} An Observable that emits the arguments * described above and then completes. * @method of * @owner Observable */ function of() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var scheduler = args[args.length - 1]; if (isScheduler_1.isScheduler(scheduler)) { args.pop(); return scheduleArray_1.scheduleArray(args, scheduler); } else { return fromArray_1.fromArray(args); } } exports.of = of; //# sourceMappingURL=of.js.map