Last change
on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | "use strict";
|
---|
| 2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 3 | var Observable_1 = require("../Observable");
|
---|
| 4 | var from_1 = require("./from");
|
---|
| 5 | var empty_1 = require("./empty");
|
---|
| 6 | function using(resourceFactory, observableFactory) {
|
---|
| 7 | return new Observable_1.Observable(function (subscriber) {
|
---|
| 8 | var resource;
|
---|
| 9 | try {
|
---|
| 10 | resource = resourceFactory();
|
---|
| 11 | }
|
---|
| 12 | catch (err) {
|
---|
| 13 | subscriber.error(err);
|
---|
| 14 | return undefined;
|
---|
| 15 | }
|
---|
| 16 | var result;
|
---|
| 17 | try {
|
---|
| 18 | result = observableFactory(resource);
|
---|
| 19 | }
|
---|
| 20 | catch (err) {
|
---|
| 21 | subscriber.error(err);
|
---|
| 22 | return undefined;
|
---|
| 23 | }
|
---|
| 24 | var source = result ? from_1.from(result) : empty_1.EMPTY;
|
---|
| 25 | var subscription = source.subscribe(subscriber);
|
---|
| 26 | return function () {
|
---|
| 27 | subscription.unsubscribe();
|
---|
| 28 | if (resource) {
|
---|
| 29 | resource.unsubscribe();
|
---|
| 30 | }
|
---|
| 31 | };
|
---|
| 32 | });
|
---|
| 33 | }
|
---|
| 34 | exports.using = using;
|
---|
| 35 | //# sourceMappingURL=using.js.map |
---|
Note:
See
TracBrowser
for help on using the repository browser.