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.

123456789101112131415161718192021222324252627282930313233
  1. /** PURE_IMPORTS_START _Observable,_from,_empty PURE_IMPORTS_END */
  2. import { Observable } from '../Observable';
  3. import { from } from './from';
  4. import { EMPTY } from './empty';
  5. export function using(resourceFactory, observableFactory) {
  6. return new Observable(function (subscriber) {
  7. var resource;
  8. try {
  9. resource = resourceFactory();
  10. }
  11. catch (err) {
  12. subscriber.error(err);
  13. return undefined;
  14. }
  15. var result;
  16. try {
  17. result = observableFactory(resource);
  18. }
  19. catch (err) {
  20. subscriber.error(err);
  21. return undefined;
  22. }
  23. var source = result ? from(result) : EMPTY;
  24. var subscription = source.subscribe(subscriber);
  25. return function () {
  26. subscription.unsubscribe();
  27. if (resource) {
  28. resource.unsubscribe();
  29. }
  30. };
  31. });
  32. }
  33. //# sourceMappingURL=using.js.map