Initial commit
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
package io.reactivex.internal.subscribers;
|
||||
|
||||
import io.reactivex.FlowableSubscriber;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.exceptions.CompositeException;
|
||||
import io.reactivex.exceptions.Exceptions;
|
||||
import io.reactivex.functions.Action;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.functions.Predicate;
|
||||
import io.reactivex.internal.subscriptions.SubscriptionHelper;
|
||||
import io.reactivex.plugins.RxJavaPlugins;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.reactivestreams.Subscription;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class ForEachWhileSubscriber<T> extends AtomicReference<Subscription> implements FlowableSubscriber<T>, Disposable {
|
||||
private static final long serialVersionUID = -4403180040475402120L;
|
||||
boolean done;
|
||||
final Action onComplete;
|
||||
final Consumer<? super Throwable> onError;
|
||||
final Predicate<? super T> onNext;
|
||||
|
||||
public ForEachWhileSubscriber(Predicate<? super T> predicate, Consumer<? super Throwable> consumer, Action action) {
|
||||
this.onNext = predicate;
|
||||
this.onError = consumer;
|
||||
this.onComplete = action;
|
||||
}
|
||||
|
||||
@Override // io.reactivex.disposables.Disposable
|
||||
public void dispose() {
|
||||
SubscriptionHelper.cancel(this);
|
||||
}
|
||||
|
||||
public boolean isDisposed() {
|
||||
return SubscriptionHelper.isCancelled(get());
|
||||
}
|
||||
|
||||
@Override // org.reactivestreams.Subscriber
|
||||
public void onComplete() {
|
||||
if (this.done) {
|
||||
return;
|
||||
}
|
||||
this.done = true;
|
||||
try {
|
||||
this.onComplete.run();
|
||||
} catch (Throwable th) {
|
||||
Exceptions.b(th);
|
||||
RxJavaPlugins.b(th);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // org.reactivestreams.Subscriber
|
||||
public void onError(Throwable th) {
|
||||
if (this.done) {
|
||||
RxJavaPlugins.b(th);
|
||||
return;
|
||||
}
|
||||
this.done = true;
|
||||
try {
|
||||
this.onError.accept(th);
|
||||
} catch (Throwable th2) {
|
||||
Exceptions.b(th2);
|
||||
RxJavaPlugins.b(new CompositeException(th, th2));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // org.reactivestreams.Subscriber
|
||||
public void onNext(T t) {
|
||||
if (this.done) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (this.onNext.a(t)) {
|
||||
return;
|
||||
}
|
||||
dispose();
|
||||
onComplete();
|
||||
} catch (Throwable th) {
|
||||
Exceptions.b(th);
|
||||
dispose();
|
||||
onError(th);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // org.reactivestreams.Subscriber
|
||||
public void onSubscribe(Subscription subscription) {
|
||||
SubscriptionHelper.setOnce(this, subscription, Long.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user