-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
2.x: FlatMap Observable with a Single #4635
Comments
Possibly; but the overall problem is the combinatorial explosion as you'd need mapping with |
Yeah I already had this regard in my mind, basically 6 new API calls would need to be created:
I understand the concern about all of the varieties however personally I feel like this would be a good addition to the public API. Especially since Completable, Maybe and Single already have those flatMap variants. Also with having those special flatMaps one would not need to convert the original Type to an Observable / Flowable anymore. I'd be happy to contribute to those. |
Sure. Also could you please add comparative benchmarks? |
You mean comparing the new methods against the old |
Yes. |
Alright I'll start with |
I'm also working on the idea described in #4584 (at https://github.com/tilal6991/RxJava/commits/2.x) to try and get rid of this combinatorial explosion - this is especially valuable if you find that hand optimizing for every variant turns out not to be worth the effort. |
The patterns will be very similar but due to the upstream and receiver types, you can't have one implementation. |
I understand - this is more to reduce the fact that all the classes are spread across the codebase without any sharing of implementation. I'm pretty sure we can consolidate code somewhat. |
Schedule has gotten tighter I don't think I can come up with anything until RC4 (this Thursday) |
Okay, I'll do them. |
Done in #4667; It's easy to write them because knowing that there's going to be at most 1 element opens up nice simplifications. |
Closing via #4667. Thanks once again |
Often times I have an Observable and want to
flatMap
all values with a Single.Imagine having
Single<Photo> getPhoto(int user)
if I wanted to flatMap it with an Observable it would look like this:
Observable.range(1, 100).flatMap(user -> getPhoto(user).toObservable())
It does the job however the Single always needs to be converted to an Observable. Are you guys open for a flatMap version which takes a Single or is there any way around this already without the need to convert the Single to an Observable?
The text was updated successfully, but these errors were encountered: