-
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(multicast): Fixes multicast with selector to create a new source …
…connection per subscriber. (#1774) Multicast with a selector function should create a new ConnectableObservable for each subscriber to the MulticastObservable. This ensures each subscriber creates a new connection to the source Observable, and don't share subscription side-effects.
- Loading branch information
Showing
5 changed files
with
50 additions
and
10 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--require source-map-support/register | ||
--require spec/support/mocha-setup-node.js | ||
--require spec-js/helpers/test-helper.js | ||
--require spec-js/helpers/ajax-helper.js | ||
--ui spec-js/helpers/testScheduler-ui.js | ||
|
||
--reporter dot | ||
--bail | ||
--full-trace | ||
--check-leaks | ||
--globals WebSocket,FormData | ||
|
||
--recursive | ||
--timeout 100000 |
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,20 +1,21 @@ | ||
import {Subject} from '../Subject'; | ||
import {Observable} from '../Observable'; | ||
import {Subscriber} from '../Subscriber'; | ||
import {Subscription} from '../Subscription'; | ||
import {ConnectableObservable} from '../observable/ConnectableObservable'; | ||
|
||
export class MulticastObservable<T> extends Observable<T> { | ||
constructor(protected source: Observable<T>, | ||
private connectable: ConnectableObservable<T>, | ||
private subjectFactory: () => Subject<T>, | ||
private selector: (source: Observable<T>) => Observable<T>) { | ||
super(); | ||
} | ||
|
||
protected _subscribe(subscriber: Subscriber<T>): Subscription { | ||
const {selector, connectable} = this; | ||
|
||
const { selector, source } = this; | ||
const connectable = new ConnectableObservable(source, this.subjectFactory); | ||
const subscription = selector(connectable).subscribe(subscriber); | ||
subscription.add(connectable.connect()); | ||
return subscription; | ||
} | ||
} | ||
} |
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