Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

subscribeTo.js 1.2KB

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