1 import { map } from './map';
2 import { from } from '../observable/from';
3 import { SimpleOuterSubscriber, SimpleInnerSubscriber, innerSubscribe } from '../innerSubscribe';
4 export function exhaustMap(project, resultSelector) {
6 return (source) => source.pipe(exhaustMap((a, i) => from(project(a, i)).pipe(map((b, ii) => resultSelector(a, b, i, ii)))));
8 return (source) => source.lift(new ExhaustMapOperator(project));
10 class ExhaustMapOperator {
11 constructor(project) {
12 this.project = project;
14 call(subscriber, source) {
15 return source.subscribe(new ExhaustMapSubscriber(subscriber, this.project));
18 class ExhaustMapSubscriber extends SimpleOuterSubscriber {
19 constructor(destination, project) {
21 this.project = project;
22 this.hasSubscription = false;
23 this.hasCompleted = false;
27 if (!this.hasSubscription) {
33 const index = this.index++;
35 result = this.project(value, index);
38 this.destination.error(err);
41 this.hasSubscription = true;
42 this._innerSub(result);
45 const innerSubscriber = new SimpleInnerSubscriber(this);
46 const destination = this.destination;
47 destination.add(innerSubscriber);
48 const innerSubscription = innerSubscribe(result, innerSubscriber);
49 if (innerSubscription !== innerSubscriber) {
50 destination.add(innerSubscription);
54 this.hasCompleted = true;
55 if (!this.hasSubscription) {
56 this.destination.complete();
60 notifyNext(innerValue) {
61 this.destination.next(innerValue);
64 this.destination.error(err);
67 this.hasSubscription = false;
68 if (this.hasCompleted) {
69 this.destination.complete();
73 //# sourceMappingURL=exhaustMap.js.map