With the RC3 changes I don't see an easy way of converting an Observable into a Single without giving a default value.
How do you feel about adding methods for that?
@abersnaze didn't like throwing because being empty. Try your API through Maybe and switchIfEmpty(Maybe.error()).
Edit wrong method name, fixed.
defaultIfEmpty(MaybeSource<T>) does not exist
Yeah sorry, switchIfEmpty() (I sometimes mix the two as defaultIfEmpty delegates to switchIfEmpty).
I don't quite see how switchIfEmpty solves my original problem. Maybe.switchIfEmpty() still returns a Maybe.
Also I'd rather have a NoSuchElementException and fail early than passing in a default value when converting an Observable to Single.
You could restore toSingle (under singleOrError), only the surface API has been removed.
So basically add to Observable + Flowable:
singleOrError
firstOrError
lastOrError
elementAtOrError
Yes.
Alright cool will do
Does singleElement() error on more than one but not on empty?
Yes, that was kept and also why firstElement is there to ignore more without signalling.
This can be closed right?
Most helpful comment
So basically add to Observable + Flowable:
singleOrErrorfirstOrErrorlastOrErrorelementAtOrError