src/main/java/io/reactivex/Maybe.java
@CheckReturnValue
    @NonNull
    @SchedulerSupport(SchedulerSupport.NONE)
    public static <T> Maybe<T> create(MaybeOnSubscribe<T> onSubscribe) {
        ObjectHelper.requireNonNull(onSubscribe, "onSubscribe is null");
        return RxJavaPlugins.onAssembly(new MaybeCreate<T>(onSubscribe));
    }
@CheckReturnValue
    @NonNull
    @SchedulerSupport(SchedulerSupport.NONE)
    public static <T> Maybe<T> create(MaybeOnSubscribe<T> onSubscribe) {
        ObjectHelper.requireNonNull(onSubscribe, "onSubscribe is null");
        return RxJavaPlugins.onAssembly(new MaybeCreate<T>(onSubscribe));
    }
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Maybe < T > create ( MaybeOnSubscribe < T > onSubscribe ) { ObjectHelper . requireNonNull ( onSubscribe , "onSubscribe is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeCreate < T > ( onSubscribe ) ) ; }
Provides an API (via a cold Maybe) that bridges the reactive world with the callback-style world.
<p>
Example:
<pre><code>
Maybe.&lt;Event&gt;create(emitter -&gt; {
Callback listener = new Callback() {
&#64;Override
public void onEvent(Event e) {
if (e.isNothing()) {
emitter.onComplete();
} else {
emitter.onSuccess(e);
}
}

&#64;Override
public void onFailure(Exception e) {
emitter.onError(e);
}
};

AutoCloseable c = api.someMethod(listener);

emitter.setCancellable(c::close);

});
</code></pre>
<dl>
<dt><b>Scheduler:</b></dt>
<dd>{@code create} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>
@param <T> the value type
@param onSubscribe the emitter that is called when a MaybeObserver subscribes to the returned {@code Maybe}
@return the new Maybe instance
@see MaybeOnSubscribe
@see Cancellable
Provides an API ( via a cold Maybe ) that bridges the reactive world with the callback - style world . <p > Example : <pre > <code > Maybe . &lt ; Event&gt ; create ( emitter - &gt ; { Callback listener = new Callback () { &#64 ; Override public void onEvent ( Event e ) { if ( e . isNothing () ) { emitter . onComplete () ; } else { emitter . onSuccess ( e ) ; } }