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

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var Observable_1 = require("../Observable");
  4. var subscribeToArray_1 = require("./subscribeToArray");
  5. var subscribeToPromise_1 = require("./subscribeToPromise");
  6. var subscribeToIterable_1 = require("./subscribeToIterable");
  7. var subscribeToObservable_1 = require("./subscribeToObservable");
  8. var isArrayLike_1 = require("./isArrayLike");
  9. var isPromise_1 = require("./isPromise");
  10. var isObject_1 = require("./isObject");
  11. var iterator_1 = require("../symbol/iterator");
  12. var observable_1 = require("../symbol/observable");
  13. exports.subscribeTo = function (result) {
  14. if (result instanceof Observable_1.Observable) {
  15. return function (subscriber) {
  16. if (result._isScalar) {
  17. subscriber.next(result.value);
  18. subscriber.complete();
  19. return undefined;
  20. }
  21. else {
  22. return result.subscribe(subscriber);
  23. }
  24. };
  25. }
  26. else if (result && typeof result[observable_1.observable] === 'function') {
  27. return subscribeToObservable_1.subscribeToObservable(result);
  28. }
  29. else if (isArrayLike_1.isArrayLike(result)) {
  30. return subscribeToArray_1.subscribeToArray(result);
  31. }
  32. else if (isPromise_1.isPromise(result)) {
  33. return subscribeToPromise_1.subscribeToPromise(result);
  34. }
  35. else if (result && typeof result[iterator_1.iterator] === 'function') {
  36. return subscribeToIterable_1.subscribeToIterable(result);
  37. }
  38. else {
  39. var value = isObject_1.isObject(result) ? 'an invalid object' : "'" + result + "'";
  40. var msg = "You provided " + value + " where a stream was expected."
  41. + ' You can provide an Observable, Promise, Array, or Iterable.';
  42. throw new TypeError(msg);
  43. }
  44. };
  45. //# sourceMappingURL=subscribeTo.js.map