90 lines
2.7 KiB
Java
90 lines
2.7 KiB
Java
package io.reactivex.internal.operators.observable;
|
|
|
|
import io.reactivex.ObservableSource;
|
|
import io.reactivex.internal.util.ExceptionHelper;
|
|
import io.reactivex.internal.util.NotificationLite;
|
|
import io.reactivex.observers.DefaultObserver;
|
|
import java.util.Iterator;
|
|
import java.util.NoSuchElementException;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class BlockingObservableMostRecent<T> implements Iterable<T> {
|
|
final ObservableSource<T> a;
|
|
final T b;
|
|
|
|
static final class MostRecentObserver<T> extends DefaultObserver<T> {
|
|
volatile Object b;
|
|
|
|
final class Iterator implements java.util.Iterator<T> {
|
|
private Object a;
|
|
|
|
Iterator() {
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public boolean hasNext() {
|
|
this.a = MostRecentObserver.this.b;
|
|
return !NotificationLite.isComplete(this.a);
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public T next() {
|
|
try {
|
|
if (this.a == null) {
|
|
this.a = MostRecentObserver.this.b;
|
|
}
|
|
if (NotificationLite.isComplete(this.a)) {
|
|
throw new NoSuchElementException();
|
|
}
|
|
if (NotificationLite.isError(this.a)) {
|
|
throw ExceptionHelper.a(NotificationLite.getError(this.a));
|
|
}
|
|
return (T) NotificationLite.getValue(this.a);
|
|
} finally {
|
|
this.a = null;
|
|
}
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public void remove() {
|
|
throw new UnsupportedOperationException("Read only iterator");
|
|
}
|
|
}
|
|
|
|
MostRecentObserver(T t) {
|
|
this.b = NotificationLite.next(t);
|
|
}
|
|
|
|
public MostRecentObserver<T>.Iterator b() {
|
|
return new Iterator();
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onComplete() {
|
|
this.b = NotificationLite.complete();
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onError(Throwable th) {
|
|
this.b = NotificationLite.error(th);
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onNext(T t) {
|
|
this.b = NotificationLite.next(t);
|
|
}
|
|
}
|
|
|
|
public BlockingObservableMostRecent(ObservableSource<T> observableSource, T t) {
|
|
this.a = observableSource;
|
|
this.b = t;
|
|
}
|
|
|
|
@Override // java.lang.Iterable
|
|
public Iterator<T> iterator() {
|
|
MostRecentObserver mostRecentObserver = new MostRecentObserver(this.b);
|
|
this.a.subscribe(mostRecentObserver);
|
|
return mostRecentObserver.b();
|
|
}
|
|
}
|