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

v3: The marble diagram for cast is incredibly misleading. #7605

Closed
derektom14 opened this issue Oct 4, 2023 · 0 comments · Fixed by #7606
Closed

v3: The marble diagram for cast is incredibly misleading. #7605

derektom14 opened this issue Oct 4, 2023 · 0 comments · Fixed by #7606

Comments

@derektom14
Copy link

Here's the current marble diagram for Observable.cast/Flowable.cast:

http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Observable.html#cast-java.lang.Class-

We see that the input is a series of shapes of different colors (red square, yellow circle, green diamond, green circle, red star), and it is cast to pentagon, so the result is a series of shapes of the input colors, but all pentagons. This would imply that the cast function somehow emits a transformation of the input object, but that isn't the case at all. It makes no transformations.

A more fitting diagram example would have an input of (red square, yellow square, green circle, blue square), effectively an Observable<Shape>, with a cast to square, for Observable<Square>. The resulting output would be a red square, then a yellow square, then an error, because a green circle is not a square. The documentation should also clearly state that a ClassCastException occurs on an incorrect cast. The ofType diagram is far more accurate.

The Single.cast and Maybe.cast diagrams are also flawed:

http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Single.html#cast-java.lang.Class-

When the input is a diamond, and the cast is to a circle, the output apparently completes with no elements, mirroring ofType(Circle.class) rather than cast(Circle.class). It should emit an exception instead.

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