Skip to content

Observable.takeUntil wrong documentation #7339

@Maragues

Description

@Maragues

According to Observable.takeUntil(ObservableSource other)'s documentation

Returns an Observable that emits the items emitted by the current Observable until a second ObservableSource emits an item.

Emphasis is mine

Looking at ObservableTakeUntil, it looks to me that onNext and onComplete are equivalent

I created this test, and the output is exactly the same

class TakeUntilTest {
    @Test
    fun `when Observable completes, then takeUntil completes`(){
        Observable.just(1, 2, 3)
            .takeUntil(Observable.empty<Unit>())
            .subscribe(
                {
                    println("Item: $it")
                },
                Timber::e,
                {
                    println("onComplete")
                }
            )
    }
    
    @Test
    fun `when Observable emits, then takeUntil completes`(){
        Observable.just(1, 2, 3)
            .takeUntil(Observable.just(Unit))
            .subscribe(
                {
                    println("Item: $it")
                },
                Timber::e,
                {
                    println("onComplete")
                }
            )
    }
}

image

According to documentation, the first test should emit 1, 2 and 3 values

Thus, I think the documentation should say something like

Returns an Observable that emits the items emitted by the current Observable until a second ObservableSource emits an item or completes successfully.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions