123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var Observable_1 = require("../Observable");
- var subscribeToArray_1 = require("./subscribeToArray");
- var subscribeToPromise_1 = require("./subscribeToPromise");
- var subscribeToIterable_1 = require("./subscribeToIterable");
- var subscribeToObservable_1 = require("./subscribeToObservable");
- var isArrayLike_1 = require("./isArrayLike");
- var isPromise_1 = require("./isPromise");
- var isObject_1 = require("./isObject");
- var iterator_1 = require("../symbol/iterator");
- var observable_1 = require("../symbol/observable");
- exports.subscribeTo = function (result) {
- if (result instanceof Observable_1.Observable) {
- return function (subscriber) {
- if (result._isScalar) {
- subscriber.next(result.value);
- subscriber.complete();
- return undefined;
- }
- else {
- return result.subscribe(subscriber);
- }
- };
- }
- else if (result && typeof result[observable_1.observable] === 'function') {
- return subscribeToObservable_1.subscribeToObservable(result);
- }
- else if (isArrayLike_1.isArrayLike(result)) {
- return subscribeToArray_1.subscribeToArray(result);
- }
- else if (isPromise_1.isPromise(result)) {
- return subscribeToPromise_1.subscribeToPromise(result);
- }
- else if (result && typeof result[iterator_1.iterator] === 'function') {
- return subscribeToIterable_1.subscribeToIterable(result);
- }
- else {
- var value = isObject_1.isObject(result) ? 'an invalid object' : "'" + result + "'";
- var msg = "You provided " + value + " where a stream was expected."
- + ' You can provide an Observable, Promise, Array, or Iterable.';
- throw new TypeError(msg);
- }
- };
- //# sourceMappingURL=subscribeTo.js.map
|