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.

fetch.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var Observable_1 = require("../../Observable");
  4. function fromFetch(input, init) {
  5. return new Observable_1.Observable(function (subscriber) {
  6. var controller = new AbortController();
  7. var signal = controller.signal;
  8. var outerSignalHandler;
  9. var abortable = true;
  10. var unsubscribed = false;
  11. if (init) {
  12. if (init.signal) {
  13. outerSignalHandler = function () {
  14. if (!signal.aborted) {
  15. controller.abort();
  16. }
  17. };
  18. init.signal.addEventListener('abort', outerSignalHandler);
  19. }
  20. init.signal = signal;
  21. }
  22. else {
  23. init = { signal: signal };
  24. }
  25. fetch(input, init).then(function (response) {
  26. abortable = false;
  27. subscriber.next(response);
  28. subscriber.complete();
  29. }).catch(function (err) {
  30. abortable = false;
  31. if (!unsubscribed) {
  32. subscriber.error(err);
  33. }
  34. });
  35. return function () {
  36. unsubscribed = true;
  37. if (abortable) {
  38. controller.abort();
  39. }
  40. };
  41. });
  42. }
  43. exports.fromFetch = fromFetch;
  44. //# sourceMappingURL=fetch.js.map