Skip to content

Commit 4c16aa6

Browse files
committed
feat(mergeAll): now supports promises, iterables and lowercase-o observables
1 parent c5239e9 commit 4c16aa6

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/operators/mergeAll-support.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import Operator from '../Operator';
33
import Subscriber from '../Subscriber';
44
import Observer from '../Observer';
55
import Subscription from '../Subscription';
6+
import OuterSubscriber from '../OuterSubscriber';
7+
import subscribeToResult from '../util/subscribeToResult';
68

79
export class MergeAllOperator<T, R> implements Operator<T, R> {
810
constructor(private concurrent: number) {
@@ -14,10 +16,11 @@ export class MergeAllOperator<T, R> implements Operator<T, R> {
1416
}
1517
}
1618

17-
export class MergeAllSubscriber<T> extends Subscriber<T> {
19+
export class MergeAllSubscriber<T, R> extends OuterSubscriber<T, R> {
1820
private hasCompleted: boolean = false;
1921
private buffer: Observable<any>[] = [];
2022
private active: number = 0;
23+
2124
constructor(destination: Observer<T>, private concurrent:number) {
2225
super(destination);
2326
}
@@ -28,7 +31,7 @@ export class MergeAllSubscriber<T> extends Subscriber<T> {
2831
this.destination.next(observable.value);
2932
} else {
3033
this.active++;
31-
this.add(observable.subscribe(new MergeAllInnerSubscriber(this.destination, this)))
34+
this.add(subscribeToResult<T, R>(this, observable));
3235
}
3336
} else {
3437
this.buffer.push(observable);
@@ -52,14 +55,4 @@ export class MergeAllSubscriber<T> extends Subscriber<T> {
5255
this.destination.complete();
5356
}
5457
}
55-
}
56-
57-
export class MergeAllInnerSubscriber<T> extends Subscriber<T> {
58-
constructor(destination: Observer<T>, private parent: MergeAllSubscriber<T>) {
59-
super(destination);
60-
}
61-
62-
_complete() {
63-
this.parent.notifyComplete(this);
64-
}
6558
}

0 commit comments

Comments
 (0)