-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Description
Here's the current marble diagram for Observable.cast/Flowable.cast:
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:
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.