趣约 v1.0.0版本的 MD5 值为:39b38c4fdd4abffa44fa3a81ea9918d4
以下内容为反编译后的 MaybeLife.java 源代码,内容仅作参考
package com.rxjava.rxlife;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.core.Maybe;
import io.reactivex.rxjava3.core.MaybeObserver;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.exceptions.Exceptions;
import io.reactivex.rxjava3.functions.Action;
import io.reactivex.rxjava3.functions.Consumer;
import io.reactivex.rxjava3.internal.functions.Functions;
import io.reactivex.rxjava3.internal.operators.maybe.MaybeCallbackObserver;
import io.reactivex.rxjava3.plugins.RxJavaPlugins;
public class MaybeLife<T> extends RxSource<MaybeObserver<? super T>> {
private final Maybe<T> upStream;
@Override
public void subscribe(Object obj) {
subscribe((MaybeObserver) ((MaybeObserver) obj));
}
@Override
public Object subscribeWith(Object obj) {
return super.subscribeWith(obj);
}
public MaybeLife(Maybe<T> maybe, Scope scope, boolean z) {
super(scope, z);
this.upStream = maybe;
}
@Override
public final Disposable subscribe() {
return subscribe(Functions.emptyConsumer(), Functions.ON_ERROR_MISSING, Functions.EMPTY_ACTION);
}
public final Disposable subscribe(Consumer<? super T> consumer) {
return subscribe(consumer, Functions.ON_ERROR_MISSING, Functions.EMPTY_ACTION);
}
public final Disposable subscribe(Consumer<? super T> consumer, Consumer<? super Throwable> consumer2) {
return subscribe(consumer, consumer2, Functions.EMPTY_ACTION);
}
public final Disposable subscribe(Consumer<? super T> consumer, Consumer<? super Throwable> consumer2, Action action) {
ObjectHelper.requireNonNull(consumer, "onSuccess is null");
ObjectHelper.requireNonNull(consumer2, "onError is null");
ObjectHelper.requireNonNull(action, "onComplete is null");
return (Disposable) subscribeWith(new MaybeCallbackObserver(consumer, consumer2, action));
}
public final void subscribe(MaybeObserver<? super T> maybeObserver) {
ObjectHelper.requireNonNull(maybeObserver, "observer is null");
MaybeObserver<? super T> onSubscribe = RxJavaPlugins.onSubscribe(this.upStream, maybeObserver);
ObjectHelper.requireNonNull(onSubscribe, "The RxJavaPlugins.onSubscribe hook returned a null MaybeObserver. Please check the handler provided to RxJavaPlugins.setOnMaybeSubscribe for invalid null returns. Further reading: https://github.com/ReactiveX/RxJava/wiki/Plugins");
try {
subscribeActual(onSubscribe);
} catch (NullPointerException e) {
throw e;
} catch (Throwable th) {
Exceptions.throwIfFatal(th);
NullPointerException nullPointerException = new NullPointerException("subscribeActual failed");
nullPointerException.initCause(th);
throw nullPointerException;
}
}
private void subscribeActual(MaybeObserver<? super T> maybeObserver) {
Maybe<T> maybe = this.upStream;
if (this.onMain) {
maybe = maybe.observeOn(AndroidSchedulers.mainThread());
}
maybe.onTerminateDetach().subscribe(new LifeMaybeObserver(maybeObserver, this.scope));
}
}