JavaScript is disabled on your browser.
Skip navigation links
  • Summary:
  • Nested |
  • Field |
  • Constr |
  • Method
  • Detail:
  • Field |
  • Constr |
  • Method
io.reactivex.rxjava3.plugins

Class RxJavaPlugins



  • public final class RxJavaPlugins
    extends Object 
    Utility class to inject handlers to certain standard RxJava operations.
    • Method Detail

      • lockdown

        public static void lockdown()
        Prevents changing the plugins from then on.

        This allows container-like environments to prevent clients messing with plugins.

      • isLockdown

        public static boolean isLockdown()
        Returns true if the plugins were locked down.
        Returns:
        true if the plugins were locked down
      • setFailOnNonBlockingScheduler

        public static void setFailOnNonBlockingScheduler(boolean enable)
        Enables or disables the blockingX operators to fail with an IllegalStateException on a non-blocking scheduler such as computation or single.

        History: 2.0.5 - experimental

        Parameters:
        enable - enable or disable the feature
        Since:
        2.1
      • isFailOnNonBlockingScheduler

        public static boolean isFailOnNonBlockingScheduler()
        Returns true if the blockingX operators fail with an IllegalStateException on a non-blocking scheduler such as computation or single.

        History: 2.0.5 - experimental

        Returns:
        true if the blockingX operators fail on a non-blocking scheduler
        Since:
        2.1
      • getComputationSchedulerHandler

        @Nullable
        public static @Nullable Function<? super Scheduler,? extends Scheduler> getComputationSchedulerHandler()
        Returns the current hook function.
        Returns:
        the hook function, may be null
      • onComputationScheduler

        @NonNull
        public static @NonNull Scheduler onComputationScheduler(@NonNull Scheduler defaultScheduler)
        Calls the associated hook function.
        Parameters:
        defaultScheduler - the hook's input value
        Returns:
        the value returned by the hook
      • onError

        public static void onError(@NonNull Throwable error)
        Called when an undeliverable error occurs.

        Undeliverable errors are those Observer.onError() invocations that are not allowed to happen on the given consumer type (Observer, Subscriber, etc.) due to protocol restrictions because the consumer has either disposed/cancelled its Disposable/Subscription or has already terminated with an onError() or onComplete() signal.

        By default, this global error handler prints the stacktrace via Throwable.printStackTrace() and calls Thread.UncaughtExceptionHandler.uncaughtException(Thread, Throwable) on the current thread.

        Note that on some platforms, the platform runtime terminates the current application with an error if such uncaught exceptions happen. In this case, it is recommended the application installs a global error handler via the setErrorHandler(Consumer) plugin method.

        Parameters:
        error - the error to report
        See Also:
        getErrorHandler(), setErrorHandler(Consumer), Error handling Wiki
      • onIoScheduler

        @NonNull
        public static @NonNull Scheduler onIoScheduler(@NonNull Scheduler defaultScheduler)
        Calls the associated hook function.
        Parameters:
        defaultScheduler - the hook's input value
        Returns:
        the value returned by the hook
      • onNewThreadScheduler

        @NonNull
        public static @NonNull Scheduler onNewThreadScheduler(@NonNull Scheduler defaultScheduler)
        Calls the associated hook function.
        Parameters:
        defaultScheduler - the hook's input value
        Returns:
        the value returned by the hook
      • onSingleScheduler

        @NonNull
        public static @NonNull Scheduler onSingleScheduler(@NonNull Scheduler defaultScheduler)
        Calls the associated hook function.
        Parameters:
        defaultScheduler - the hook's input value
        Returns:
        the value returned by the hook
      • reset

        public static void reset()
        Removes all handlers and resets to default behavior.
      • setComputationSchedulerHandler

        public static void setComputationSchedulerHandler(@Nullable Function<? super Scheduler,? extends Scheduler> handler)
        Sets the specific hook function.
        Parameters:
        handler - the hook function to set, null allowed
      • setErrorHandler

        public static void setErrorHandler(@Nullable Consumer<? super Throwable> handler)
        Sets the specific hook function.
        Parameters:
        handler - the hook function to set, null allowed
      • setInitComputationSchedulerHandler

        public static void setInitComputationSchedulerHandler(@Nullable Function<? super Supplier<Scheduler>,? extends Scheduler> handler)
        Sets the specific hook function.
        Parameters:
        handler - the hook function to set, null allowed, but the function may not return null
      • setInitIoSchedulerHandler

        public static void setInitIoSchedulerHandler(@Nullable Function<? super Supplier<Scheduler>,? extends Scheduler> handler)
        Sets the specific hook function.
        Parameters:
        handler - the hook function to set, null allowed, but the function may not return null
      • setInitNewThreadSchedulerHandler

        public static void setInitNewThreadSchedulerHandler(@Nullable Function<? super Supplier<Scheduler>,? extends Scheduler> handler)
        Sets the specific hook function.
        Parameters:
        handler - the hook function to set, null allowed, but the function may not return null
      • setInitSingleSchedulerHandler

        public static void setInitSingleSchedulerHandler(@Nullable Function<? super Supplier<Scheduler>,? extends Scheduler> handler)
        Sets the specific hook function.
        Parameters:
        handler - the hook function to set, null allowed, but the function may not return null
      • setIoSchedulerHandler

        public static void setIoSchedulerHandler(@Nullable Function<? super Scheduler,? extends Scheduler> handler)
        Sets the specific hook function.
        Parameters:
        handler - the hook function to set, null allowed
      • setNewThreadSchedulerHandler

        public static void setNewThreadSchedulerHandler(@Nullable Function<? super Scheduler,? extends Scheduler> handler)
        Sets the specific hook function.
        Parameters:
        handler - the hook function to set, null allowed
      • setScheduleHandler

        public static void setScheduleHandler(@Nullable Function<? super Runnable,? extends Runnable> handler)
        Sets the specific hook function.
        Parameters:
        handler - the hook function to set, null allowed
      • setSingleSchedulerHandler

        public static void setSingleSchedulerHandler(@Nullable Function<? super Scheduler,? extends Scheduler> handler)
        Sets the specific hook function.
        Parameters:
        handler - the hook function to set, null allowed
      • getOnMaybeAssembly

        @Nullable
        public static @Nullable Function<? super Maybe,? extends Maybe> getOnMaybeAssembly()
        Returns the current hook function.
        Returns:
        the hook function, may be null
      • getOnSingleAssembly

        @Nullable
        public static @Nullable Function<? super Single,? extends Single> getOnSingleAssembly()
        Returns the current hook function.
        Returns:
        the hook function, may be null
      • setOnCompletableAssembly

        public static void setOnCompletableAssembly(@Nullable Function<? super Completable,? extends Completable> onCompletableAssembly)
        Sets the specific hook function.
        Parameters:
        onCompletableAssembly - the hook function to set, null allowed
      • setOnFlowableAssembly

        public static void setOnFlowableAssembly(@Nullable Function<? super Flowable,? extends Flowable> onFlowableAssembly)
        Sets the specific hook function.
        Parameters:
        onFlowableAssembly - the hook function to set, null allowed
      • setOnMaybeAssembly

        public static void setOnMaybeAssembly(@Nullable Function<? super Maybe,? extends Maybe> onMaybeAssembly)
        Sets the specific hook function.
        Parameters:
        onMaybeAssembly - the hook function to set, null allowed
      • setOnConnectableFlowableAssembly

        public static void setOnConnectableFlowableAssembly(@Nullable Function<? super ConnectableFlowable,? extends ConnectableFlowable> onConnectableFlowableAssembly)
        Sets the specific hook function.
        Parameters:
        onConnectableFlowableAssembly - the hook function to set, null allowed
      • setOnFlowableSubscribe

        public static void setOnFlowableSubscribe(@Nullable BiFunction<? super Flowable,? super Subscriber,? extends Subscriber> onFlowableSubscribe)
        Sets the specific hook function.
        Parameters:
        onFlowableSubscribe - the hook function to set, null allowed
      • setOnMaybeSubscribe

        public static void setOnMaybeSubscribe(@Nullable BiFunction<? super Maybe,MaybeObserver,? extends MaybeObserver> onMaybeSubscribe)
        Sets the specific hook function.
        Parameters:
        onMaybeSubscribe - the hook function to set, null allowed
      • setOnObservableAssembly

        public static void setOnObservableAssembly(@Nullable Function<? super Observable,? extends Observable> onObservableAssembly)
        Sets the specific hook function.
        Parameters:
        onObservableAssembly - the hook function to set, null allowed
      • setOnConnectableObservableAssembly

        public static void setOnConnectableObservableAssembly(@Nullable Function<? super ConnectableObservable,? extends ConnectableObservable> onConnectableObservableAssembly)
        Sets the specific hook function.
        Parameters:
        onConnectableObservableAssembly - the hook function to set, null allowed
      • setOnObservableSubscribe

        public static void setOnObservableSubscribe(@Nullable BiFunction<? super Observable,? super Observer,? extends Observer> onObservableSubscribe)
        Sets the specific hook function.
        Parameters:
        onObservableSubscribe - the hook function to set, null allowed
      • setOnSingleAssembly

        public static void setOnSingleAssembly(@Nullable Function<? super Single,? extends Single> onSingleAssembly)
        Sets the specific hook function.
        Parameters:
        onSingleAssembly - the hook function to set, null allowed
      • setOnSingleSubscribe

        public static void setOnSingleSubscribe(@Nullable BiFunction<? super Single,? super SingleObserver,? extends SingleObserver> onSingleSubscribe)
        Sets the specific hook function.
        Parameters:
        onSingleSubscribe - the hook function to set, null allowed
      • onSubscribe

        @NonNull
        public static <T> @NonNull Subscriber<? super T> onSubscribe(@NonNull Flowable<T> source,
         @NonNull Subscriber<? super T> subscriber)
        Calls the associated hook function.
        Type Parameters:
        T - the value type
        Parameters:
        source - the hook's input value
        subscriber - the subscriber
        Returns:
        the value returned by the hook
      • onSubscribe

        @NonNull
        public static <T> @NonNull Observer<? super T> onSubscribe(@NonNull Observable<T> source,
         @NonNull Observer<? super T> observer)
        Calls the associated hook function.
        Type Parameters:
        T - the value type
        Parameters:
        source - the hook's input value
        observer - the observer
        Returns:
        the value returned by the hook
      • onSubscribe

        @NonNull
        public static <T> @NonNull SingleObserver<? super T> onSubscribe(@NonNull Single<T> source,
         @NonNull SingleObserver<? super T> observer)
        Calls the associated hook function.
        Type Parameters:
        T - the value type
        Parameters:
        source - the hook's input value
        observer - the observer
        Returns:
        the value returned by the hook
      • onSubscribe

        @NonNull
        public static <T> @NonNull MaybeObserver<? super T> onSubscribe(@NonNull Maybe<T> source,
         @NonNull MaybeObserver<? super T> observer)
        Calls the associated hook function.
        Type Parameters:
        T - the value type
        Parameters:
        source - the hook's input value
        observer - the subscriber
        Returns:
        the value returned by the hook
      • onSubscribe

        @NonNull
        public static <T> @NonNull Subscriber<? super T>[] onSubscribe(@NonNull ParallelFlowable<T> source,
         @NonNull Subscriber<? super T>[] subscribers)
        Calls the associated hook function.
        Type Parameters:
        T - the value type
        Parameters:
        source - the hook's input value
        subscribers - the array of subscribers
        Returns:
        the value returned by the hook
      • onAssembly

        @NonNull
        public static <T> @NonNull Maybe<T> onAssembly(@NonNull Maybe<T> source)
        Calls the associated hook function.
        Type Parameters:
        T - the value type
        Parameters:
        source - the hook's input value
        Returns:
        the value returned by the hook
      • onAssembly

        @NonNull
        public static <T> @NonNull Flowable<T> onAssembly(@NonNull Flowable<T> source)
        Calls the associated hook function.
        Type Parameters:
        T - the value type
        Parameters:
        source - the hook's input value
        Returns:
        the value returned by the hook
      • onAssembly

        @NonNull
        public static <T> @NonNull Observable<T> onAssembly(@NonNull Observable<T> source)
        Calls the associated hook function.
        Type Parameters:
        T - the value type
        Parameters:
        source - the hook's input value
        Returns:
        the value returned by the hook
      • onAssembly

        @NonNull
        public static <T> @NonNull Single<T> onAssembly(@NonNull Single<T> source)
        Calls the associated hook function.
        Type Parameters:
        T - the value type
        Parameters:
        source - the hook's input value
        Returns:
        the value returned by the hook
      • setOnParallelAssembly

        public static void setOnParallelAssembly(@Nullable Function<? super ParallelFlowable,? extends ParallelFlowable> handler)
        Sets the specific hook function.

        History: 2.0.6 - experimental; 2.1 - beta

        Parameters:
        handler - the hook function to set, null allowed
        Since:
        2.2
      • setOnParallelSubscribe

        public static void setOnParallelSubscribe(@Nullable BiFunction<? super ParallelFlowable,? super Subscriber[],? extends Subscriber[]> handler)
        Sets the specific hook function.

        History: 3.0.11 - experimental

        Parameters:
        handler - the hook function to set, null allowed
        Since:
        3.1.0
      • onAssembly

        @NonNull
        public static <T> @NonNull ParallelFlowable<T> onAssembly(@NonNull ParallelFlowable<T> source)
        Calls the associated hook function.

        History: 2.0.6 - experimental; 2.1 - beta

        Type Parameters:
        T - the value type of the source
        Parameters:
        source - the hook's input value
        Returns:
        the value returned by the hook
        Since:
        2.2
      • onBeforeBlocking

        public static boolean onBeforeBlocking()
        Called before an operator attempts a blocking operation such as awaiting a condition or signal and should return true to indicate the operator should not block but throw an IllegalArgumentException.

        History: 2.0.5 - experimental

        Returns:
        true if the blocking should be prevented
        Since:
        2.1
        See Also:
        setFailOnNonBlockingScheduler(boolean)
      • setOnBeforeBlocking

        public static void setOnBeforeBlocking(@Nullable BooleanSupplier handler)
        Set the handler that is called when an operator attempts a blocking await; the handler should return true to prevent the blocking and to signal an IllegalStateException instead.

        History: 2.0.5 - experimental

        Parameters:
        handler - the handler to set, null resets to the default handler that always returns false
        Since:
        2.1
        See Also:
        onBeforeBlocking()
      • getOnBeforeBlocking

        @Nullable
        public static @Nullable BooleanSupplier getOnBeforeBlocking()
        Returns the current blocking handler or null if no custom handler is set.

        History: 2.0.5 - experimental

        Returns:
        the current blocking handler or null if not specified
        Since:
        2.1
      • createComputationScheduler

        @NonNull
        public static @NonNull Scheduler createComputationScheduler(@NonNull ThreadFactory threadFactory)
        Create an instance of the default Scheduler used for Schedulers.computation() except using threadFactory for thread creation.

        History: 2.0.5 - experimental

        Parameters:
        threadFactory - thread factory to use for creating worker threads. Note that this takes precedence over any system properties for configuring new thread creation. Cannot be null.
        Returns:
        the created Scheduler instance
        Since:
        2.1
      • createIoScheduler

        @NonNull
        public static @NonNull Scheduler createIoScheduler(@NonNull ThreadFactory threadFactory)
        Create an instance of the default Scheduler used for Schedulers.io() except using threadFactory for thread creation.

        History: 2.0.5 - experimental

        Parameters:
        threadFactory - thread factory to use for creating worker threads. Note that this takes precedence over any system properties for configuring new thread creation. Cannot be null.
        Returns:
        the created Scheduler instance
        Since:
        2.1
      • createNewThreadScheduler

        @NonNull
        public static @NonNull Scheduler createNewThreadScheduler(@NonNull ThreadFactory threadFactory)
        Create an instance of the default Scheduler used for Schedulers.newThread() except using threadFactory for thread creation.

        History: 2.0.5 - experimental

        Parameters:
        threadFactory - thread factory to use for creating worker threads. Note that this takes precedence over any system properties for configuring new thread creation. Cannot be null.
        Returns:
        the created Scheduler instance
        Since:
        2.1
      • createSingleScheduler

        @NonNull
        public static @NonNull Scheduler createSingleScheduler(@NonNull ThreadFactory threadFactory)
        Create an instance of the default Scheduler used for Schedulers.single() except using threadFactory for thread creation.

        History: 2.0.5 - experimental

        Parameters:
        threadFactory - thread factory to use for creating worker threads. Note that this takes precedence over any system properties for configuring new thread creation. Cannot be null.
        Returns:
        the created Scheduler instance
        Since:
        2.1
      • createExecutorScheduler

        @NonNull
        public static @NonNull Scheduler createExecutorScheduler(@NonNull Executor executor,
         boolean interruptibleWorker,
         boolean fair)
        Create an instance of a Scheduler by wrapping an existing Executor.

        This method allows creating an Executor-backed Scheduler before the Schedulers class would initialize the standard Schedulers.

        Parameters:
        executor - the Executor to wrap and turn into a Scheduler.
        interruptibleWorker - if true, the tasks submitted to the Scheduler.Worker will be interrupted when the task is disposed.
        fair - if true, tasks submitted to the Scheduler or Worker will be executed by the underlying Executor one after the other, still in a FIFO and non-overlapping manner, but allows interleaving with other tasks submitted to the underlying Executor. If false, the underlying FIFO scheme will execute as many tasks as it can before giving up the underlying Executor thread.
        Returns:
        the new Scheduler wrapping the Executor
        Since:
        3.1.0
Skip navigation links
  • Summary:
  • Nested |
  • Field |
  • Constr |
  • Method
  • Detail:
  • Field |
  • Constr |
  • Method

AltStyle によって変換されたページ (->オリジナル) /