com.gs.api.accelrx.context.rxjava3.ContextPropagatorOnMaybeAssemblyAction Maven / Gradle / Ivy
The newest version!
package com.gs.api.accelrx.context.rxjava3;
import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Maybe;
import io.reactivex.rxjava3.core.MaybeObserver;
import io.reactivex.rxjava3.functions.Function;
import java.util.concurrent.Executor;
@SuppressWarnings("rawtypes")
public class ContextPropagatorOnMaybeAssemblyAction implements Function {
private final ThreadContext threadContext;
public ContextPropagatorOnMaybeAssemblyAction(ThreadContext threadContext) {
this.threadContext = threadContext;
}
@Override
@SuppressWarnings({"rawtypes", "unchecked"})
public Maybe apply(Maybe maybe) throws Throwable {
return new ContextPropagatorMaybe<>(maybe, threadContext.currentContextExecutor());
}
private static final class ContextPropagatorMaybe extends Maybe {
private final Maybe source;
private final Executor contextExecutor;
public ContextPropagatorMaybe(Maybe single, Executor contextExecutor) {
this.source = single;
this.contextExecutor = contextExecutor;
}
@Override
protected void subscribeActual(@NonNull MaybeObserver super T> observer) {
contextExecutor.execute(() -> source.subscribe(observer));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy