-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mergeAll): add source subscription to composite before actually s…
…ubscribing (#2479) Add subscriptions for source Observables to mergeAll composite subscription before actually subscribing to any of these Observables, so that if source Observable emits synchronously and consumer of mergeAll unsubscribes at that moment (for example `take` operator), subscription to source is unsubscribed as well and Observable stops emitting. Closes #2476
- Loading branch information
Showing
3 changed files
with
52 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,26 @@ | ||
|
||
import { ObservableInput } from '../types'; | ||
import { Subscription } from '../Subscription'; | ||
import { InnerSubscriber } from '../InnerSubscriber'; | ||
import { OuterSubscriber } from '../OuterSubscriber'; | ||
import { Subscriber } from '../Subscriber'; | ||
import { subscribeTo } from './subscribeTo'; | ||
|
||
export function subscribeToResult<T, R>(outerSubscriber: OuterSubscriber<T, R>, | ||
result: any, | ||
outerValue?: T, | ||
outerIndex?: number): Subscription; | ||
export function subscribeToResult<T>(outerSubscriber: OuterSubscriber<any, any>, | ||
result: ObservableInput<T>, | ||
outerValue?: T, | ||
outerIndex?: number): Subscription | void { | ||
const destination = new InnerSubscriber(outerSubscriber, outerValue, outerIndex); | ||
|
||
export function subscribeToResult<T, R>( | ||
outerSubscriber: OuterSubscriber<T, R>, | ||
result: any, | ||
outerValue?: T, | ||
outerIndex?: number, | ||
destination?: Subscriber<any> | ||
): Subscription; | ||
export function subscribeToResult<T, R>( | ||
outerSubscriber: OuterSubscriber<T, R>, | ||
result: any, | ||
outerValue?: T, | ||
outerIndex?: number, | ||
destination: Subscriber<any> = new InnerSubscriber(outerSubscriber, outerValue, outerIndex) | ||
): Subscription | void { | ||
if (destination.closed) { | ||
return; | ||
} | ||
return subscribeTo(result)(destination); | ||
} |