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

Support io.reactivex.Maybe #846

Closed
geralt-encore opened this issue Nov 9, 2017 · 11 comments
Closed

Support io.reactivex.Maybe #846

geralt-encore opened this issue Nov 9, 2017 · 11 comments
Assignees
Milestone

Comments

@geralt-encore
Copy link
Collaborator

I'll work on this as soon as initial RxJava 2 support will be merged

@geralt-encore geralt-encore added this to the v3.0.0 milestone Nov 9, 2017
@geralt-encore geralt-encore self-assigned this Nov 9, 2017
@nikitin-da
Copy link
Collaborator

It will be great!

@geralt-encore
Copy link
Collaborator Author

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?

@geralt-encore
Copy link
Collaborator Author

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?

@nikitin-da
Copy link
Collaborator

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

@geralt-encore
Copy link
Collaborator Author

geralt-encore commented Nov 15, 2017

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?

@nikitin-da
Copy link
Collaborator

nikitin-da commented Nov 15, 2017

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 =(

@geralt-encore
Copy link
Collaborator Author

Yeah, now I see... Have to think more about it then

@nikitin-da
Copy link
Collaborator

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

@geralt-encore
Copy link
Collaborator Author

I'll look into it tomorrow with a clear head =)

@nikitin-da
Copy link
Collaborator

I will prepare some draft for this idea in 2 hours

@nikitin-da
Copy link
Collaborator

I suppose something like this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants