-
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
API Design Review: Instance Concat/Merge/Flatten/Zip #687
Comments
Another issue about the instance implementation, is the conflict of the static method signature and the instance one. For example, |
Given that there's
But the price is high:
As you can see, I don't like the idea ;-) |
Would it be worth while to move all of the static operators to a different class (maybe something like ObservableOfObservables.java and ObservableOfNumbers.java) so that they won't clash with the instance revisions? |
It would not accept another The intent of the instance methods is not for use cases such as It is to flatten/merge/zip an For example: Thus the instance signature would be
One could argue that about the entire Rx chaining pattern. Why have instance methods at all if code cosmetics was not a concern?
It offers support for interesting use cases where an Flatten specifically is considered for recursive flattening such that it could work on Whether that's confusing or not is in the eye of the beholder ... I can argue that Perhaps the "confusing" part could be reduced by only having a
It's little different than when
It's doing something that static methods don't permit, particularly if we allow I'm not convinced either way on whether this is a good or bad thing, but the following is preferable code: o.map().filter().map().flatten().take() than breaking the order of the chain into this: flatten(o.map().filter().map()).take() |
@benjchristensen now it makes more sense ;-) Recursive flattening of heterogeneous Observables sounds interesting... |
A reminder that this and #295 are related. |
We now have |
An idea that has floated for the past year (including #295) is to add instance method for
flatten
. During API review this came up again along with instance methods for each of the combination operators:concat
,merge
/flatten
,zip
.Because of how Java types work and without targeted extension methods we can not only make these apply to
Observable<Observable<T>>
and be type safe.We could however do things like ...
If we have an `Observable<Observable>:
observable.flatten().cast(MyType.class)
observable.flattenTo(MyType.class)
If we have an
Observable<T>
it would basically just pass-thru without applying the flattening since it's already flat./cc @headinthebox and @jhusain
The text was updated successfully, but these errors were encountered: