You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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, forObservable<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 aClassCastException
occurs on an incorrect cast. TheofType
diagram is far more accurate.The
Single.cast
andMaybe.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 thancast(Circle.class)
. It should emit an exception instead.The text was updated successfully, but these errors were encountered: