use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class ObservableIntervalRange method subscribeActual.
@Override
public void subscribeActual(Observer<? super Long> observer) {
IntervalRangeObserver is = new IntervalRangeObserver(observer, start, end);
observer.onSubscribe(is);
Scheduler sch = scheduler;
if (sch instanceof TrampolineScheduler) {
Worker worker = sch.createWorker();
is.setResource(worker);
worker.schedulePeriodically(is, initialDelay, period, unit);
} else {
Disposable d = sch.schedulePeriodicallyDirect(is, initialDelay, period, unit);
is.setResource(d);
}
}
use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class ObservableRepeat method subscribeActual.
@Override
public void subscribeActual(Observer<? super T> observer) {
SequentialDisposable sd = new SequentialDisposable();
observer.onSubscribe(sd);
RepeatObserver<T> rs = new RepeatObserver<>(observer, count != Long.MAX_VALUE ? count - 1 : Long.MAX_VALUE, sd, source);
rs.subscribeNext();
}
use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class ObservableBufferTimed method subscribeActual.
@Override
protected void subscribeActual(Observer<? super U> t) {
if (timespan == timeskip && maxSize == Integer.MAX_VALUE) {
source.subscribe(new BufferExactUnboundedObserver<>(new SerializedObserver<>(t), bufferSupplier, timespan, unit, scheduler));
return;
}
Scheduler.Worker w = scheduler.createWorker();
if (timespan == timeskip) {
source.subscribe(new BufferExactBoundedObserver<>(new SerializedObserver<>(t), bufferSupplier, timespan, unit, maxSize, restartTimerOnMaxSize, w));
return;
}
// Can't use maxSize because what to do if a buffer is full but its
// timespan hasn't been elapsed?
source.subscribe(new BufferSkipBoundedObserver<>(new SerializedObserver<>(t), bufferSupplier, timespan, timeskip, unit, w));
}
use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class ObservableDelay method subscribeActual.
@Override
@SuppressWarnings("unchecked")
public void subscribeActual(Observer<? super T> t) {
Observer<T> observer;
if (delayError) {
observer = (Observer<T>) t;
} else {
observer = new SerializedObserver<>(t);
}
Scheduler.Worker w = scheduler.createWorker();
source.subscribe(new DelayObserver<>(observer, delay, unit, w, delayError));
}
use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class ObservableCollectWithCollectorTest method collectorAccumulatorDropSignalsToObservable.
@Test
public void collectorAccumulatorDropSignalsToObservable() throws Throwable {
TestHelper.withErrorTracking(errors -> {
Observable<Integer> source = new Observable<Integer>() {
@Override
protected void subscribeActual(Observer<? super Integer> observer) {
observer.onSubscribe(Disposable.empty());
observer.onNext(1);
observer.onNext(2);
observer.onError(new IOException());
observer.onComplete();
}
};
source.collect(new Collector<Integer, Integer, Integer>() {
@Override
public Supplier<Integer> supplier() {
return () -> 1;
}
@Override
public BiConsumer<Integer, Integer> accumulator() {
return (a, b) -> {
throw new TestException();
};
}
@Override
public BinaryOperator<Integer> combiner() {
return (a, b) -> a + b;
}
@Override
public Function<Integer, Integer> finisher() {
return a -> a;
}
@Override
public Set<Characteristics> characteristics() {
return Collections.emptySet();
}
}).toObservable().test().assertFailure(TestException.class);
TestHelper.assertUndeliverable(errors, 0, IOException.class);
});
}
Aggregations