Skip to content

Observable.replay - a bug or a feature? #6920

Closed
@arkivanov

Description

@arkivanov

Version: 3.0.0

Hello! In the ConnectableObservable java docs this following is written:

Disposing the connection will reset the {@code ConnectableFlowable} to its fresh state and there is no need to call {@code reset()} in this case.

So I think If I dispose the connection then I don't need to call reset, it should be in its initial state. However the following test fails. But if you uncomment the reset() call then it passes:

    @Test
    fun testReplay() {
        val subject = PublishSubject.create<Int>()
        val replay = subject.replay()

        var observer = replay.test() // subscribe
        val disposable = replay.connect() // connect
        subject.onNext(1)
        observer.dispose() // unsubscribe
        disposable.dispose() // disconnect
//        sharedStream.reset()

        observer = replay.test() // subscribe again
        replay.connect() // connect again
        subject.onNext(0)

        observer.assertValues(0) // Actual value is 1, but if reset was called then it will be 0
    }

Could you please clarify whether it is a bug or expected behaviour. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions