Skip to content
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

merge(with:) breaks RxSwift's merge() #238

Closed
akolov opened this issue Sep 18, 2019 · 21 comments · Fixed by #241
Closed

merge(with:) breaks RxSwift's merge() #238

akolov opened this issue Sep 18, 2019 · 21 comments · Fixed by #241
Assignees

Comments

@akolov
Copy link

akolov commented Sep 18, 2019

Hi, I've stumbled upon an issue where importing RxSwiftExt breaks behavior of Observable.of(...).merge().

Given the following sample code:

Observable.of(a, b)
  .merge()
  .debug("+++ TEST")
  .subscribe(onNext: { x in
    print("BOO \(x)")
  })
  .disposed(by: disposeBag) // disposeBag is declared somewhere else and should retain the observable

  a.onNext("a")
  b.onNext("b")

Now, depending on whether I import RxSwiftExt or not produces drastically different result.

First, output without RxSwiftExt, everything works as expected:

+++ TEST -> Event next(a)
BOO a
+++ TEST -> Event next(b)
BOO b

Next, if I import RxSwiftExt, result is something completely unexpected. I get event completed and whole thing disposed at the end:

+++ TEST -> subscribed
+++ TEST -> Event next(RxSwift.PublishSubject<Swift.String>)
BOO RxSwift.PublishSubject<Swift.String>
+++ TEST -> Event next(RxSwift.PublishSubject<Swift.String>)
BOO RxSwift.PublishSubject<Swift.String>
+++ TEST -> Event completed
+++ TEST -> isDisposed

In fact, if I step into merge() when RxSwiftExt is imported, it actually goes inside merge(with:) method.

I can reliably reproduce this with RxSwift 5.0.1 and RxSwiftExt 5.1.1, both built with Carthage using Xcode 10 (10G8) and Xcode 11 GM 2 (11A491c).

Is this expected behavior or am I doing something wrong here?

I'm attaching a sample project I used to pinpoint the issue, please run carthage bootstrap to install RxSwift and RxSwiftExt.

merge-issue.zip

@freak4pc
Copy link
Member

Hey, this definitely doesn't seem like an issue with the framework as these two methods have entirely different signatures.

@jdisho could you take a look at his example perhaps?

@jdisho
Copy link
Member

jdisho commented Sep 18, 2019

Thanks for pointing it out. I will have a look asap 😊

@jdisho jdisho self-assigned this Sep 18, 2019
@cliss
Copy link
Contributor

cliss commented Sep 18, 2019

+1. My project breaks with 5.1.1 but works with 5.0.0. All of my build errors in 5.1.1 were due to issues with merge().

@freak4pc
Copy link
Member

Hey @jdisho - can you let me know if you'll be able to take a look in the next day or two? No problem if not, but I want to know since otherwise I'll just carve out some time to look into it :)

@jdisho
Copy link
Member

jdisho commented Sep 22, 2019

Sorry for the late reply and not finding the time this weekend. Definitely, I will have a look tomorrow @freak4pc 😊

Sent with GitHawk

@jdisho
Copy link
Member

jdisho commented Sep 24, 2019

I see the problem... 🤔

Screenshot 2019-09-24 at 15 04 02

@jdisho
Copy link
Member

jdisho commented Sep 24, 2019

We can either rename to mergeWith(_ others:) or, convert the others to an array rather than having it as a sequence.

Any other suggestion?

@freak4pc
Copy link
Member

the former isn't great because we already have zip(with:)
Would converting to an array work here ? Seems reasonable to me.

@cliss
Copy link
Contributor

cliss commented Oct 2, 2019

+1 to the idea of using an array. 😇

@freak4pc
Copy link
Member

freak4pc commented Oct 2, 2019

Cool, @cliss - any way for you to confirm that changing the method to use an array would solve the ambiguity for your code base ? I'll try taking a look myself tomorrow or so and push a PR.

@cliss
Copy link
Contributor

cliss commented Oct 3, 2019

Point me to a branch and I'm happy to give it a shot!

@freak4pc
Copy link
Member

freak4pc commented Oct 3, 2019

Hey @cliss - it's on the mergeWithArray branch :)
Thank you!

@akolov
Copy link
Author

akolov commented Oct 3, 2019

It definitely solves issues I was having with merge.

@freak4pc
Copy link
Member

freak4pc commented Oct 3, 2019

@cliss - would appreciate you letting me know as well before I'm cutting a new release :) thanks @akolov !

@cliss
Copy link
Contributor

cliss commented Oct 7, 2019

Crap, I'm so sorry; just saw this. Will test first thing tomorrow morning.

My utmost apologies!

@cliss
Copy link
Contributor

cliss commented Oct 7, 2019

@freak4pc Concur with @akolov; the mergeWithArray branch fixed my build. 🎉

Apologies, again, for the delay!

@freak4pc
Copy link
Member

Merged it, will be out in a new release by next week most likely :)

@cliss
Copy link
Contributor

cliss commented Nov 26, 2019

@freak4pc bump 😇

@freak4pc
Copy link
Member

Oh yikes! Thought I took care of this since I merged it 🤦‍♂
I just put a reminder to cut a release tomorrow. Thanks for the reminder! @cliss

@freak4pc
Copy link
Member

@cliss and others - 5.2.0 was just released 🎉

@cliss
Copy link
Contributor

cliss commented Dec 3, 2019

Thanks @freak4pc! 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants