subscribeTo.js 1.5 KB

12345678910111213141516171819202122232425262728293031
  1. /** PURE_IMPORTS_START _subscribeToArray,_subscribeToPromise,_subscribeToIterable,_subscribeToObservable,_isArrayLike,_isPromise,_isObject,_symbol_iterator,_symbol_observable PURE_IMPORTS_END */
  2. import { subscribeToArray } from './subscribeToArray';
  3. import { subscribeToPromise } from './subscribeToPromise';
  4. import { subscribeToIterable } from './subscribeToIterable';
  5. import { subscribeToObservable } from './subscribeToObservable';
  6. import { isArrayLike } from './isArrayLike';
  7. import { isPromise } from './isPromise';
  8. import { isObject } from './isObject';
  9. import { iterator as Symbol_iterator } from '../symbol/iterator';
  10. import { observable as Symbol_observable } from '../symbol/observable';
  11. export var subscribeTo = function (result) {
  12. if (!!result && typeof result[Symbol_observable] === 'function') {
  13. return subscribeToObservable(result);
  14. }
  15. else if (isArrayLike(result)) {
  16. return subscribeToArray(result);
  17. }
  18. else if (isPromise(result)) {
  19. return subscribeToPromise(result);
  20. }
  21. else if (!!result && typeof result[Symbol_iterator] === 'function') {
  22. return subscribeToIterable(result);
  23. }
  24. else {
  25. var value = isObject(result) ? 'an invalid object' : "'" + result + "'";
  26. var msg = "You provided " + value + " where a stream was expected."
  27. + ' You can provide an Observable, Promise, Array, or Iterable.';
  28. throw new TypeError(msg);
  29. }
  30. };
  31. //# sourceMappingURL=subscribeTo.js.map