Last change
on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
977 bytes
|
Line | |
---|
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
|
---|
Note:
See
TracBrowser
for help on using the repository browser.