-
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
fix: make share, publish, et al. operator calls referentially transparent #6410
fix: make share, publish, et al. operator calls referentially transparent #6410
Conversation
I'm generally in favor of this change. It seems like a bug that may have been introduced at some point. Can we prove that out? Is there a version of RxJS 5 or 6 where these new tests would pass? |
Looking at the operators in HEAD of the
And it's the same with HEAD of the Going back further and looking at the first 'lettable' versions of the operators:
|
change publish operator to use factory change publishReplay operator to not share ReplaySubject fixes issue ReactiveX#5411
b5aa06a
to
56919fa
Compare
So this is a regression in |
I guess the workaround for this if you really WANTED this behavior in, say, const olderPublish = () => {
const subject = new Subject();
return connect({
connector: () => subject
})
} Perhaps we should document that? Or maybe the comment here will be enough. I doubt it will be an issue, TBH. |
Description:
This PR incorporates the fixes and tests in #5585 and also fixes and tests the
share
,shareReplay
,publishBehavior
andpublishLast
operators.The problem that is fixed can be described as follows:
share
- must be referentially transparent. Otherwise, those operators cannot be used in calls to the staticpipe
function (to create partial pipelines).pipe
method.IMO, the changes are a bug fix, rather than a breaking change. The behaviour is changed. However, the behaviour prior to this change was not sensible and I cannot see how anyone could possibly be relying upon it. Any callers using a partial pipeline composed using the static
pipe
function and one of the affected operators would see wildly different behaviour - subscriptions to completely unexpected sources - depending upon the order in which subscriptions were made.Related issue (if exists): #5411 #5585