Closed geralt-encore closed 6 years ago
It will be great!
I've started to look into Maybe implementation and not everything is quite clear.
To be able to properly implement MaybeOnSubscribeExecuteAsBlocking
there has to be a way to distinguish between empty and non-empty cases. Since Result
is generic the only way to achieve it is to make executeAsBlocking
nullable again. Is it ok or am I missing something?
Another question. What will be correct for empty list/cursor cases: to return an empty list/cursor or to just complete stream without an emission?
Dumn, my bad=(
preparedOperation
's Result
must be must be Optional
and unwrapperd nullable value at the same time =(
Maybe we should create separate WrappedResult
generic type, that will duplicate Result
for listOfObject
and cursor
?
Otherwise, if we are ok that result of Maybe
is Optional
than we can create separate MaybeOnSubscribeExecuteAsBlocking
implementations for Optional<T>
, List<T>
and so on.
//cc @artem-zinnatullin
What will be correct for empty list/cursor cases: to return an empty list/cursor or to just complete stream without an emission?
I guess we should complete stream without an emission, otherwise it will be the same asRxSingle
I guess we should complete stream without an emission, otherwise it will be the same asRxSingle
Had the same thoughts and just wanted to verify it.
Not sure if I got what you were saying about preparedOperation
's Result
.
Isn't actual wrapping happens on Interceptor
level so we can return null for Maybe
case and still be able to use Optional
for Single
?
Not quite so, interceptor must return value of the same type as prepared operation uses
So all other methods (executeAsBlocking
, asRxFlowable
) must return values with the same type =(
Yeah, now I see... Have to think more about it then
As I said before maybe we can add WrappedResult
type in prepared operation declaration
executeAsBlocking
, asRxMaybe
and interceptors will continue to work with Result
, nut asRxSingle
and asRxFlowable
will return WrappedResult
. That will be Optional
only for PreparedGet
.
So SingleOnSubscribeExecuteAsBlocking
and FlowableOnSubscribeExecuteAsBlocking
will be responsible for optional creation
I'll look into it tomorrow with a clear head =)
I will prepare some draft for this idea in 2 hours
I suppose something like this
I'll work on this as soon as initial RxJava 2 support will be merged