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.8KB

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