-
Notifications
You must be signed in to change notification settings - Fork 7.6k
2.x: Maybe for lazy Optional #4436
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
Conversation
@@ -5730,7 +5731,7 @@ public final void blockingSubscribe(Subscriber<? super T> subscriber) { | |||
@SchedulerSupport(SchedulerSupport.NONE) | |||
public final <B> Flowable<List<T>> buffer(Publisher<B> boundaryIndicator, final int initialCapacity) { | |||
return buffer(boundaryIndicator, Functions.<T>createArrayList(initialCapacity)); | |||
} | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these misaligned?
You referenced Java 8 types in your code. |
My problem with adding another base type is the increased maintenance cost. Currently we have 3 + 4 types in the major versions and it is likely adding a new operator, overload or making a fix has to be done for all of them. I'm one-man armying RxJava for a considerable time now but I have my limits. Therefore my suggestion is that you have this Flowable<Integer> source = Flowable.range(1, 10);
Maybe<Integer> mb = source.to(Maybe.reduceFlowable((a, b) -> a + b));
mb.filter(v -> false).subscribe(
System.out::println, Throwable::printStackTrace, () -> System.out.println("Done"));
mb.toFlowable().subscribe(
System.out::println, Throwable::printStackTrace, () -> System.out.println("Done")); |
As I mentioned my plans were to greatly increase the coupling between Observable & Flowable to Single & Maybe by having the various operators that return exactly 1 or sometimes 1 value to these two types. |
Current coverage is 71.96% (diff: 0.07%)@@ 2.x #4436 diff @@
==========================================
Files 453 499 +46
Lines 32399 33691 +1292
Methods 0 0
Messages 0 0
Branches 5216 5299 +83
==========================================
- Hits 24336 24246 -90
- Misses 6034 7431 +1397
+ Partials 2029 2014 -15
|
I'm willing to accept |
How about you just contribute |
Also Reactor has the Mono type exactly for this purpose, I suggest you try that first. |
I'm not strictly opposed because
appeals to me, but I don't have a really strong feeling without using it more. |
Okay then, let's merge this and see how it works out. |
Please don't post PRs targeting Maybe - I'm working on cleaning it up a bit (plus a few other classes if I find something wrong); the code copied from an older commit of the other types. |
In #4321 I hit on the problem of needing a lazy object that could either be zero or one value. In that issue the idea of switching the return value of
reduce(R, Func2<R,T,R>)
fromObservable<R>
toSingle<R>
because that operator can only ever produce an Observable that emits exactly one value. The problem was thatreduce(Func2<T,T,T>)
could not be changed toSingle<T>
because the source Observable could be empty and therefore not produce one and only one value.To solve this problem I mentioned we could create a lazy type that represents either 1 or no value could fill the gap between
Completable
andSingle<T>
.This PR is for the introduction of the
Maybe<T>
type.