
io.reactiverse.reactivecontexts.propagators.rxjava2.ContextPropagatorOnFlowableAssemblyAction Maven / Gradle / Ivy
package io.reactiverse.reactivecontexts.propagators.rxjava2;
import org.reactivestreams.Subscriber;
import io.reactiverse.reactivecontexts.core.Context;
import io.reactiverse.reactivecontexts.core.ContextState;
import io.reactivex.Flowable;
import io.reactivex.functions.Function;
public class ContextPropagatorOnFlowableAssemblyAction implements Function {
@Override
public Flowable apply(Flowable t) throws Exception {
return new ContextPropagatorFlowable(t);
}
public class ContextPropagatorFlowable extends Flowable {
private Flowable source;
private ContextState context;
public ContextPropagatorFlowable(Flowable t) {
this.source = t;
this.context = Context.capture();
}
@Override
protected void subscribeActual(Subscriber super T> observer) {
ContextState previousContext = context.install();
try {
source.subscribe(observer);
}finally {
previousContext.restore();
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy