Skip to content

Observable.takeUntil wrong documentation #7339

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

Closed
Maragues opened this issue Sep 23, 2021 · 4 comments · Fixed by #7341
Closed

Observable.takeUntil wrong documentation #7339

Maragues opened this issue Sep 23, 2021 · 4 comments · Fixed by #7341

Comments

@Maragues
Copy link

Maragues commented Sep 23, 2021

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!

@akarnokd
Copy link
Member

Yes. PR welcome.

@Maragues
Copy link
Author

Maragues commented Sep 23, 2021

What do you use to generate marble diagrams? This https://rx-marbles-online.herokuapp.com/ ?

It'd help to add whichever tool you use to contributing documentation https://github.com/ReactiveX/RxJava/blob/3.x/CONTRIBUTING.md, as well as wording guidelines for documentation

@akarnokd
Copy link
Member

Don't worry about the diagram, I have an Excel spreadsheet for them.

@akarnokd
Copy link
Member

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

Successfully merging a pull request may close this issue.

2 participants