Class RxJavaBridge


  • public final class RxJavaBridge
    extends java.lang.Object
    Utility class to convert between RxJava 2 and RxJava 3 components.
    Since:
    3.0.0
    • Method Detail

      • toV2Flowable

        public static <T> Flowable<T> toV2Flowable​(Flowable<T> source)
        Wraps a V3 Flowable and exposes it as a V2 Flowable.
        Type Parameters:
        T - the element type of the sequence
        Parameters:
        source - the source V3 Flowable
        Returns:
        the wrapper V2 Flowable
      • toV3Flowable

        public static <T> Flowable<T> toV3Flowable​(Flowable<T> source)
        Wraps a V2 Flowable and exposes it as a V3 Flowable.
        Type Parameters:
        T - the element type of the sequence
        Parameters:
        source - the source V2 Flowable
        Returns:
        the wrapper V3 Flowable
      • toV3Flowable

        public static <T> FlowableConverter<T,​Flowable<T>> toV3Flowable()
        Returns the shared singleton instance of a V2 Flowable converter that when applied in V2 Flowable.as(io.reactivex.FlowableConverter)-based fluent conversions, produces a V3 Flowable instance.
        Type Parameters:
        T - the element type of the sequence
        Returns:
        the shared singleton converter instance
      • toV2Observable

        public static <T> Observable<T> toV2Observable​(Observable<T> source)
        Wraps a V3 Observable and exposes it as a V2 Observable.
        Type Parameters:
        T - the element type of the sequence
        Parameters:
        source - the source V3 Observable
        Returns:
        the wrapper V2 Observable
      • toV3Observable

        public static <T> Observable<T> toV3Observable​(Observable<T> source)
        Wraps a V2 Observable and exposes it as a V3 Observable.
        Type Parameters:
        T - the element type of the sequence
        Parameters:
        source - the source V2 Observable
        Returns:
        the wrapper V3 Observable
      • toV3Observable

        public static <T> ObservableConverter<T,​Observable<T>> toV3Observable()
        Returns the shared singleton instance of a V2 Observable converter that when applied in V2 Observable.as(io.reactivex.ObservableConverter)-based fluent conversions, produces a V3 Observable instance.
        Type Parameters:
        T - the element type of the sequence
        Returns:
        the shared singleton converter instance
      • toV2Maybe

        public static <T> Maybe<T> toV2Maybe​(Maybe<T> source)
        Wraps a V3 Maybe and exposes it as a V2 Maybe.
        Type Parameters:
        T - the element type of the sequence
        Parameters:
        source - the source V3 Maybe
        Returns:
        the wrapper V2 Maybe
      • toV3Maybe

        public static <T> Maybe<T> toV3Maybe​(Maybe<T> source)
        Wraps a V2 Maybe and exposes it as a V3 Maybe.
        Type Parameters:
        T - the element type of the sequence
        Parameters:
        source - the source V2 Maybe
        Returns:
        the wrapper V3 Maybe
      • toV3Maybe

        public static <T> MaybeConverter<T,​Maybe<T>> toV3Maybe()
        Returns the shared singleton instance of a V2 Maybe converter that when applied in V2 Maybe.as(io.reactivex.MaybeConverter)-based fluent conversions, produces a V3 Maybe instance.
        Type Parameters:
        T - the element type of the sequence
        Returns:
        the shared singleton converter instance
      • toV2Maybe

        public static <T> MaybeConverter<T,​Maybe<T>> toV2Maybe()
        Returns the shared singleton instance of a V3 Maybe converter that when applied in V3 Maybe.to(io.reactivex.rxjava3.core.MaybeConverter)-based fluent conversions, produces a V2 Maybe instance.
        Type Parameters:
        T - the element type of the sequence
        Returns:
        the shared singleton converter instance
      • toV2Single

        public static <T> Single<T> toV2Single​(Single<T> source)
        Wraps a V3 Single and exposes it as a V2 Single.
        Type Parameters:
        T - the element type of the sequence
        Parameters:
        source - the source V3 Single
        Returns:
        the wrapper V2 Single
      • toV3Single

        public static <T> Single<T> toV3Single​(Single<T> source)
        Wraps a V2 Single and exposes it as a V3 Single.
        Type Parameters:
        T - the element type of the sequence
        Parameters:
        source - the source V2 Single
        Returns:
        the wrapper V3 Single
      • toV3Single

        public static <T> SingleConverter<T,​Single<T>> toV3Single()
        Returns the shared singleton instance of a V2 Single converter that when applied in V2 Single.as(io.reactivex.SingleConverter)-based fluent conversions, produces a V3 Single instance.
        Type Parameters:
        T - the element type of the sequence
        Returns:
        the shared singleton converter instance
      • toV2Single

        public static <T> SingleConverter<T,​Single<T>> toV2Single()
        Returns the shared singleton instance of a V3 Single converter that when applied in V3 Single.to(io.reactivex.rxjava3.core.SingleConverter)-based fluent conversions, produces a V2 Single instance.
        Type Parameters:
        T - the element type of the sequence
        Returns:
        the shared singleton converter instance
      • toV2Completable

        public static Completable toV2Completable​(Completable source)
        Wraps a V3 Completable and exposes it as a V2 Completable.
        Parameters:
        source - the source V3 Completable
        Returns:
        the wrapper V2 Completable
      • toV3Completable

        public static Completable toV3Completable​(Completable source)
        Wraps a V2 Completable and exposes it as a V3 Completable.
        Parameters:
        source - the source V2 Completable
        Returns:
        the wrapper V3 Completable
      • toV2Disposable

        public static Disposable toV2Disposable​(Disposable disposable)
        Wraps a V3 Disposable and exposes it as a V2 Disposable.
        Parameters:
        disposable - the source V3 Disposable
        Returns:
        the wrapper V2 Disposable
      • toV3Disposable

        public static Disposable toV3Disposable​(Disposable disposable)
        Wraps a V2 Disposable and exposes it as a V3 Disposable.
        Parameters:
        disposable - the source V2 Disposable
        Returns:
        the wrapper V3 Disposable
      • toV2Scheduler

        public static Scheduler toV2Scheduler​(Scheduler scheduler)
        Wraps a V3 Scheduler and exposes it as a V2 Scheduler.
        Parameters:
        scheduler - the source V3 Scheduler
        Returns:
        the wrapper V2 Scheduler
      • toV3Scheduler

        public static Scheduler toV3Scheduler​(Scheduler scheduler)
        Wraps a V2 Scheduler and exposes it as a V3 Scheduler.
        Parameters:
        scheduler - the source V2 Scheduler
        Returns:
        the wrapper V3 Scheduler
      • startUsingV2Schedulers

        public static void startUsingV2Schedulers()
        Wraps all standard V2 Schedulers into V3 Schedulers and installs scheduler hooks in the V3 RxJavaPlugins so that both RxJava 2 and RxJava 3 use the same backing scheduler implementations.
      • stopUsingV2Schedulers

        public static void stopUsingV2Schedulers()
        Stop using the V2 standard schedulers by resetting the V3 scheduler hooks to their default (null) handlers in the V3 RxJavaPlugins.
      • startUsingV3Schedulers

        public static void startUsingV3Schedulers()
        Wraps all standard V3 Schedulers into V2 Schedulers and installs scheduler hooks in the V2 RxJavaPlugins so that both RxJava 2 and RxJava 3 use the same backing scheduler implementations.
      • stopUsingV3Schedulers

        public static void stopUsingV3Schedulers()
        Stop using the V3 standard schedulers by resetting the V2 scheduler hooks to their default (null) handlers in the V2 RxJavaPlugins.