Skip to content

Commit 52dc050

Browse files
authored
2.x: start reimplementing Maybe with up-to-date javadoc, tests and algo (#4454)
1 parent b8a3320 commit 52dc050

File tree

107 files changed

+4828
-4000
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+4828
-4000
lines changed

src/main/java/io/reactivex/Completable.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import io.reactivex.internal.functions.*;
2424
import io.reactivex.internal.operators.completable.*;
2525
import io.reactivex.internal.operators.flowable.FlowableDelaySubscriptionOther;
26+
import io.reactivex.internal.operators.maybe.MaybeFromCompletable;
2627
import io.reactivex.internal.operators.observable.ObservableDelaySubscriptionOther;
2728
import io.reactivex.internal.operators.single.SingleDelayWithCompletable;
2829
import io.reactivex.internal.subscribers.completable.*;
@@ -1622,7 +1623,23 @@ public final <U> U to(Function<? super Completable, U> converter) {
16221623
public final <T> Flowable<T> toFlowable() {
16231624
return RxJavaPlugins.onAssembly(new CompletableToFlowable<T>(this));
16241625
}
1625-
1626+
1627+
/**
1628+
* Converts this Single into a {@link Maybe}.
1629+
* <p>
1630+
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Single.toObservable.png" alt="">
1631+
* <dl>
1632+
* <dt><b>Scheduler:</b></dt>
1633+
* <dd>{@code toCompletable} does not operate by default on a particular {@link Scheduler}.</dd>
1634+
* </dl>
1635+
*
1636+
* @param <T> the value type
1637+
* @return an {@link Maybe} that emits a single item T or an error.
1638+
*/
1639+
public final <T> Maybe<T> toMaybe() {
1640+
return RxJavaPlugins.onAssembly(new MaybeFromCompletable<T>(this));
1641+
}
1642+
16261643
/**
16271644
* Returns an NbpObservable which when subscribed to subscribes to this Completable and
16281645
* relays the terminal events to the subscriber.

src/main/java/io/reactivex/Flowable.java

Lines changed: 238 additions & 225 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)