All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gs.api.accelrx.context.rxjava3.RxJava3ContextPropagator Maven / Gradle / Ivy

package com.gs.api.accelrx.context.rxjava3;

import io.reactiverse.reactivecontexts.core.ContextPropagator;
import io.reactivex.rxjava3.plugins.RxJavaPlugins;

// todo: consider using a custom Scheduler instead that decorates other Schedulers with the context propagation
public class RxJava3ContextPropagator implements ContextPropagator {

    @Override
    public void setup() {
        ThreadContext threadContext = new ThreadContext();

        RxJavaPlugins.setOnSingleSubscribe(new ContextPropagatorOnSingleSubscribeAction(threadContext));
        RxJavaPlugins.setOnCompletableSubscribe(new ContextPropagatorOnCompletableSubscribeAction(threadContext));
        RxJavaPlugins.setOnFlowableSubscribe(new ContextPropagatorOnFlowableSubscribeAction(threadContext));
        RxJavaPlugins.setOnMaybeSubscribe(new ContextPropagatorOnMaybeSubscribeAction(threadContext));
        RxJavaPlugins.setOnObservableSubscribe(new ContextPropagatorOnObservableSubscribeAction(threadContext));

        // todo: consider optimisation to not perform any assembly for Observers that have SchedulerSupport.NONE
        RxJavaPlugins.setOnSingleAssembly(new ContextPropagatorOnSingleAssemblyAction(threadContext));
        RxJavaPlugins.setOnCompletableAssembly(new ContextPropagatorOnCompletableAssemblyAction(threadContext));
        RxJavaPlugins.setOnFlowableAssembly(new ContextPropagatorOnFlowableAssemblyAction(threadContext));
        RxJavaPlugins.setOnMaybeAssembly(new ContextPropagatorOnMaybeAssemblyAction(threadContext));
        RxJavaPlugins.setOnObservableAssembly(new ContextPropagatorOnObservableAssemblyAction(threadContext));
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy