JavaScript is disabled on your browser.
Skip navigation links
  • Summary:
  • Nested |
  • Field |
  • Constr |
  • Method
  • Detail:
  • Field |
  • Constr |
  • Method
io.reactivex.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 Function<? super Scheduler,? extends Scheduler> getComputationSchedulerHandler()
        Returns the current hook function.
        Returns:
        the hook function, may be null
      • getErrorHandler

        @Nullable
        public static Consumer<? super Throwable> getErrorHandler()
        Returns the a hook consumer.
        Returns:
        the hook consumer, may be null
      • getInitComputationSchedulerHandler

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

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

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

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

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

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

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

        @NonNull
        public static Scheduler initComputationScheduler(@NonNull Callable<Scheduler> defaultScheduler)
        Calls the associated hook function.
        Parameters:
        defaultScheduler - a Callable which returns the hook's input value
        Returns:
        the value returned by the hook, not null
        Throws:
        NullPointerException - if the callable parameter or its result are null
      • initIoScheduler

        @NonNull
        public static Scheduler initIoScheduler(@NonNull Callable<Scheduler> defaultScheduler)
        Calls the associated hook function.
        Parameters:
        defaultScheduler - a Callable which returns the hook's input value
        Returns:
        the value returned by the hook, not null
        Throws:
        NullPointerException - if the callable parameter or its result are null
      • initNewThreadScheduler

        @NonNull
        public static Scheduler initNewThreadScheduler(@NonNull Callable<Scheduler> defaultScheduler)
        Calls the associated hook function.
        Parameters:
        defaultScheduler - a Callable which returns the hook's input value
        Returns:
        the value returned by the hook, not null
        Throws:
        NullPointerException - if the callable parameter or its result are null
      • initSingleScheduler

        @NonNull
        public static Scheduler initSingleScheduler(@NonNull Callable<Scheduler> defaultScheduler)
        Calls the associated hook function.
        Parameters:
        defaultScheduler - a Callable which returns the hook's input value
        Returns:
        the value returned by the hook, not null
        Throws:
        NullPointerException - if the callable parameter or its result are null
      • onComputationScheduler

        @NonNull
        public static 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 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 Scheduler onNewThreadScheduler(@NonNull Scheduler defaultScheduler)
        Calls the associated hook function.
        Parameters:
        defaultScheduler - the hook's input value
        Returns:
        the value returned by the hook
      • onSchedule

        @NonNull
        public static Runnable onSchedule(@NonNull Runnable run)
        Called when a task is scheduled.
        Parameters:
        run - the runnable instance
        Returns:
        the replacement runnable
      • onSingleScheduler

        @NonNull
        public static 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 Callable<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 Callable<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 Callable<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 Callable<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
      • getOnCompletableAssembly

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

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

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

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

        @Nullable
        public static Function<? super Observable,? extends Observable> getOnObservableAssembly()
        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> 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> 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> 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> 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
      • onAssembly

        @NonNull
        public static <T> 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> 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> 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> 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
      • onAssembly

        @NonNull
        public static Completable onAssembly(@NonNull Completable source)
        Calls the associated hook function.
        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
      • getOnParallelAssembly

        @Nullable
        public static Function<? super ParallelFlowable,? extends ParallelFlowable> getOnParallelAssembly()
        Returns the current hook function.

        History: 2.0.6 - experimental; 2.1 - beta

        Returns:
        the hook function, may be null
        Since:
        2.2
      • onAssembly

        @NonNull
        public static <T> 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 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 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 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 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 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
Skip navigation links
  • Summary:
  • Nested |
  • Field |
  • Constr |
  • Method
  • Detail:
  • Field |
  • Constr |
  • Method

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