Skip to content

Clarify behaviour in JavaDoc of switchOnNext() with respect to completions #3576

@grodin

Description

@grodin

The JavaDoc of switchOnNext() doesn't currently say anything about how the resulting Observable will complete.

The marble diagram implies (but not totally clearly) that if an inner Observable completes after an outer onNext(), that completion is swallowed, and if an inner Observable completes after the outer Observable completes, that the resulting Observable also completes.

However, there's no info about what happens in an inner Observable completes before an outer onNext(). Does the resulting Observable complete at that point or not?

I've read the tests, and it seems the answer is that the resulting Observable will complete exactly when the following happen, in this order:

  1. the outer Observable completes (implying that the current inner Observable will never be switched to any other);
  2. the current inner Observable completes.

And that the resulting Observable won't complete under any other circumstances.

Firstly, is my understanding correct, and secondly, can the JavaDoc be improved?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions