Actualizacion maquina principal
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / _esm5 / internal / operators / switchMap.js
1 /** PURE_IMPORTS_START tslib,_OuterSubscriber,_InnerSubscriber,_util_subscribeToResult,_map,_observable_from PURE_IMPORTS_END */
2 import * as tslib_1 from "tslib";
3 import { OuterSubscriber } from '../OuterSubscriber';
4 import { InnerSubscriber } from '../InnerSubscriber';
5 import { subscribeToResult } from '../util/subscribeToResult';
6 import { map } from './map';
7 import { from } from '../observable/from';
8 export function switchMap(project, resultSelector) {
9     if (typeof resultSelector === 'function') {
10         return function (source) { return source.pipe(switchMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
11     }
12     return function (source) { return source.lift(new SwitchMapOperator(project)); };
13 }
14 var SwitchMapOperator = /*@__PURE__*/ (function () {
15     function SwitchMapOperator(project) {
16         this.project = project;
17     }
18     SwitchMapOperator.prototype.call = function (subscriber, source) {
19         return source.subscribe(new SwitchMapSubscriber(subscriber, this.project));
20     };
21     return SwitchMapOperator;
22 }());
23 var SwitchMapSubscriber = /*@__PURE__*/ (function (_super) {
24     tslib_1.__extends(SwitchMapSubscriber, _super);
25     function SwitchMapSubscriber(destination, project) {
26         var _this = _super.call(this, destination) || this;
27         _this.project = project;
28         _this.index = 0;
29         return _this;
30     }
31     SwitchMapSubscriber.prototype._next = function (value) {
32         var result;
33         var index = this.index++;
34         try {
35             result = this.project(value, index);
36         }
37         catch (error) {
38             this.destination.error(error);
39             return;
40         }
41         this._innerSub(result, value, index);
42     };
43     SwitchMapSubscriber.prototype._innerSub = function (result, value, index) {
44         var innerSubscription = this.innerSubscription;
45         if (innerSubscription) {
46             innerSubscription.unsubscribe();
47         }
48         var innerSubscriber = new InnerSubscriber(this, value, index);
49         var destination = this.destination;
50         destination.add(innerSubscriber);
51         this.innerSubscription = subscribeToResult(this, result, undefined, undefined, innerSubscriber);
52         if (this.innerSubscription !== innerSubscriber) {
53             destination.add(this.innerSubscription);
54         }
55     };
56     SwitchMapSubscriber.prototype._complete = function () {
57         var innerSubscription = this.innerSubscription;
58         if (!innerSubscription || innerSubscription.closed) {
59             _super.prototype._complete.call(this);
60         }
61         this.unsubscribe();
62     };
63     SwitchMapSubscriber.prototype._unsubscribe = function () {
64         this.innerSubscription = null;
65     };
66     SwitchMapSubscriber.prototype.notifyComplete = function (innerSub) {
67         var destination = this.destination;
68         destination.remove(innerSub);
69         this.innerSubscription = null;
70         if (this.isStopped) {
71             _super.prototype._complete.call(this);
72         }
73     };
74     SwitchMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
75         this.destination.next(innerValue);
76     };
77     return SwitchMapSubscriber;
78 }(OuterSubscriber));
79 //# sourceMappingURL=switchMap.js.map