-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support .Publish(...) #1629
Comments
Would you elaborate bit more? so far I know current Line 15 in 34cdef5
|
The operator aka function publish(source, selector) {
return Rx.Observable.create(ob => {
var xs = source.publish();
return selector(xs).subscribe(ob).add(xs.connect());
});
} Similar to publish in RxJS 4 and Rx.Net.
|
Yeah, I think this makes sense to implement. |
I'll try to introduce those changes. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
For reference, the Rx Design Guidelines 5.10 suggest to use this operator.
The operator
.publish()
returns anConnectableObservable
, this means you first need to subscribe all your sources,.connect()
it, keep a reference to your connect to prevent leaks, and then you also end up with a hot observable, so downstream subscribers better be ready as well.Most of the time you only want to duplicate a stream locally. RxJS 4 and many other Rx implementations allow you to write
Here we use publish to peek at the next item in the source. Another favorite of mine is
Because often you want to use a source for its own window-boundary.
This operator is very similar to
.let
, but avoid subscribing to the source twice. Useful on cold observables, but also to avoid the overhead of subscribing multiple times to a hot source. (imagine you use this trick 4x in a row withlet
, you end up with 2^4th subscriptions.)The text was updated successfully, but these errors were encountered: