source: trip-planner-front/node_modules/rxjs/_esm2015/internal/observable/using.js@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 898 bytes
Line 
1import { Observable } from '../Observable';
2import { from } from './from';
3import { EMPTY } from './empty';
4export function using(resourceFactory, observableFactory) {
5 return new Observable(subscriber => {
6 let resource;
7 try {
8 resource = resourceFactory();
9 }
10 catch (err) {
11 subscriber.error(err);
12 return undefined;
13 }
14 let result;
15 try {
16 result = observableFactory(resource);
17 }
18 catch (err) {
19 subscriber.error(err);
20 return undefined;
21 }
22 const source = result ? from(result) : EMPTY;
23 const subscription = source.subscribe(subscriber);
24 return () => {
25 subscription.unsubscribe();
26 if (resource) {
27 resource.unsubscribe();
28 }
29 };
30 });
31}
32//# sourceMappingURL=using.js.map
Note: See TracBrowser for help on using the repository browser.