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

RxJava2Debug changes behavior of replay().refCount() #14

Open
Rajin9601 opened this issue May 2, 2019 · 0 comments
Open

RxJava2Debug changes behavior of replay().refCount() #14

Rajin9601 opened this issue May 2, 2019 · 0 comments

Comments

@Rajin9601
Copy link

RxJava version : 2.2.8 & 2.2.1 (tested in both versions)
RxJava2Debug version : 1.4.0

Code (in Kotlin, in Android)

val tmp = Observable.just(Unit)
    .flatMap {
        Observable.just(1, 2).delay(1000, TimeUnit.MILLISECONDS)
    }.doOnNext { Log.i("TEST", "onNext: " + it.toString())}
    .replay(1).refCount()

tmp.subscribeBy { // subscription 1
    Log.i("TEST", "sub1 : $it")
}

Completable.complete()
    .delay(5000, TimeUnit.MILLISECONDS)
    .subscribeBy {
        tmp.subscribeBy { // subscription 2
            Log.i("TEST", "sub2 : $it")
        }
        tmp.subscribeBy { // subscription 3
            Log.i("TEST", "sub3 : $it")
        }
    }

Log

2019-04-30 16:52:38.364 31138-31449/com.app.sample I/TEST: onNext: 1
2019-04-30 16:52:38.364 31138-31449/com.app.sample I/TEST: sub1 : 1
2019-04-30 16:52:38.364 31138-31449/com.app.sample I/TEST: onNext: 2
2019-04-30 16:52:38.364 31138-31449/com.app.sample I/TEST: sub1 : 2

2019-04-30 16:52:42.367 31138-31450/com.app.sample I/TEST: sub2 : 2

2019-04-30 16:52:43.376 31138-31510/com.app.sample I/TEST: onNext: 1
2019-04-30 16:52:43.377 31138-31510/com.app.sample I/TEST: sub3 : 1
2019-04-30 16:52:43.377 31138-31510/com.app.sample I/TEST: onNext: 2
2019-04-30 16:52:43.377 31138-31510/com.app.sample I/TEST: sub3 : 2

Explanation

At the time of subscription 2, I expected connectable observable from replay(1) to start over and emit 1 and 2, just like subscription 3. However, subscription 2 only emits 2.

When I turn off RxJava2Debug, this works as expected like (ReactiveX/RxJava#6471 (comment)).

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

No branches or pull requests

1 participant