public final class RxJavaPlugins
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static Scheduler |
createComputationScheduler(java.util.concurrent.ThreadFactory threadFactory)
Create an instance of the default
Scheduler used for Schedulers.computation()
except using threadFactory for thread creation. |
static Scheduler |
createIoScheduler(java.util.concurrent.ThreadFactory threadFactory)
Create an instance of the default
Scheduler used for Schedulers.io()
except using threadFactory for thread creation. |
static Scheduler |
createNewThreadScheduler(java.util.concurrent.ThreadFactory threadFactory)
Create an instance of the default
Scheduler used for Schedulers.newThread()
except using threadFactory for thread creation. |
static Scheduler |
createSingleScheduler(java.util.concurrent.ThreadFactory threadFactory)
Create an instance of the default
Scheduler used for Schedulers.single()
except using threadFactory for thread creation. |
static Function<? super Scheduler,? extends Scheduler> |
getComputationSchedulerHandler()
Returns the current hook function.
|
static Consumer<? super java.lang.Throwable> |
getErrorHandler()
Returns the a hook consumer.
|
static Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> |
getInitComputationSchedulerHandler()
Returns the current hook function.
|
static Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> |
getInitIoSchedulerHandler()
Returns the current hook function.
|
static Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> |
getInitNewThreadSchedulerHandler()
Returns the current hook function.
|
static Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> |
getInitSingleSchedulerHandler()
Returns the current hook function.
|
static Function<? super Scheduler,? extends Scheduler> |
getIoSchedulerHandler()
Returns the current hook function.
|
static Function<? super Scheduler,? extends Scheduler> |
getNewThreadSchedulerHandler()
Returns the current hook function.
|
static BooleanSupplier |
getOnBeforeBlocking()
Returns the current blocking handler or null if no custom handler
is set.
|
static Function<? super Completable,? extends Completable> |
getOnCompletableAssembly()
Returns the current hook function.
|
static BiFunction<? super Completable,? super CompletableObserver,? extends CompletableObserver> |
getOnCompletableSubscribe()
Returns the current hook function.
|
static Function<? super ConnectableFlowable,? extends ConnectableFlowable> |
getOnConnectableFlowableAssembly()
Returns the current hook function.
|
static Function<? super ConnectableObservable,? extends ConnectableObservable> |
getOnConnectableObservableAssembly()
Returns the current hook function.
|
static Function<? super Flowable,? extends Flowable> |
getOnFlowableAssembly()
Returns the current hook function.
|
static BiFunction<? super Flowable,? super org.reactivestreams.Subscriber,? extends org.reactivestreams.Subscriber> |
getOnFlowableSubscribe()
Returns the current hook function.
|
static Function<? super Maybe,? extends Maybe> |
getOnMaybeAssembly()
Returns the current hook function.
|
static BiFunction<? super Maybe,? super MaybeObserver,? extends MaybeObserver> |
getOnMaybeSubscribe()
Returns the current hook function.
|
static Function<? super Observable,? extends Observable> |
getOnObservableAssembly()
Returns the current hook function.
|
static BiFunction<? super Observable,? super Observer,? extends Observer> |
getOnObservableSubscribe()
Returns the current hook function.
|
static Function<? super ParallelFlowable,? extends ParallelFlowable> |
getOnParallelAssembly()
Returns the current hook function.
|
static Function<? super Single,? extends Single> |
getOnSingleAssembly()
Returns the current hook function.
|
static BiFunction<? super Single,? super SingleObserver,? extends SingleObserver> |
getOnSingleSubscribe()
Returns the current hook function.
|
static Function<? super java.lang.Runnable,? extends java.lang.Runnable> |
getScheduleHandler()
Returns the current hook function.
|
static Function<? super Scheduler,? extends Scheduler> |
getSingleSchedulerHandler()
Returns the current hook function.
|
static Scheduler |
initComputationScheduler(java.util.concurrent.Callable<Scheduler> defaultScheduler)
Calls the associated hook function.
|
static Scheduler |
initIoScheduler(java.util.concurrent.Callable<Scheduler> defaultScheduler)
Calls the associated hook function.
|
static Scheduler |
initNewThreadScheduler(java.util.concurrent.Callable<Scheduler> defaultScheduler)
Calls the associated hook function.
|
static Scheduler |
initSingleScheduler(java.util.concurrent.Callable<Scheduler> defaultScheduler)
Calls the associated hook function.
|
static boolean |
isFailOnNonBlockingScheduler()
Returns true if the blockingX operators fail
with an IllegalStateException on a non-blocking scheduler
such as computation or single.
|
static boolean |
isLockdown()
Returns true if the plugins were locked down.
|
static void |
lockdown()
Prevents changing the plugins from then on.
|
static Completable |
onAssembly(Completable source)
Calls the associated hook function.
|
static <T> ConnectableFlowable<T> |
onAssembly(ConnectableFlowable<T> source)
Calls the associated hook function.
|
static <T> ConnectableObservable<T> |
onAssembly(ConnectableObservable<T> source)
Calls the associated hook function.
|
static <T> Flowable<T> |
onAssembly(Flowable<T> source)
Calls the associated hook function.
|
static <T> Maybe<T> |
onAssembly(Maybe<T> source)
Calls the associated hook function.
|
static <T> Observable<T> |
onAssembly(Observable<T> source)
Calls the associated hook function.
|
static <T> ParallelFlowable<T> |
onAssembly(ParallelFlowable<T> source)
Calls the associated hook function.
|
static <T> Single<T> |
onAssembly(Single<T> source)
Calls the associated hook function.
|
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.
|
static Scheduler |
onComputationScheduler(Scheduler defaultScheduler)
Calls the associated hook function.
|
static void |
onError(java.lang.Throwable error)
Called when an undeliverable error occurs.
|
static Scheduler |
onIoScheduler(Scheduler defaultScheduler)
Calls the associated hook function.
|
static Scheduler |
onNewThreadScheduler(Scheduler defaultScheduler)
Calls the associated hook function.
|
static java.lang.Runnable |
onSchedule(java.lang.Runnable run)
Called when a task is scheduled.
|
static Scheduler |
onSingleScheduler(Scheduler defaultScheduler)
Calls the associated hook function.
|
static CompletableObserver |
onSubscribe(Completable source,
CompletableObserver observer)
Calls the associated hook function.
|
static <T> org.reactivestreams.Subscriber<? super T> |
onSubscribe(Flowable<T> source,
org.reactivestreams.Subscriber<? super T> subscriber)
Calls the associated hook function.
|
static <T> MaybeObserver<? super T> |
onSubscribe(Maybe<T> source,
MaybeObserver<? super T> subscriber)
Calls the associated hook function.
|
static <T> Observer<? super T> |
onSubscribe(Observable<T> source,
Observer<? super T> observer)
Calls the associated hook function.
|
static <T> SingleObserver<? super T> |
onSubscribe(Single<T> source,
SingleObserver<? super T> observer)
Calls the associated hook function.
|
static void |
reset()
Removes all handlers and resets to default behavior.
|
static void |
setComputationSchedulerHandler(Function<? super Scheduler,? extends Scheduler> handler)
Sets the specific hook function.
|
static void |
setErrorHandler(Consumer<? super java.lang.Throwable> handler)
Sets the specific hook function.
|
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.
|
static void |
setInitComputationSchedulerHandler(Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> handler)
Sets the specific hook function.
|
static void |
setInitIoSchedulerHandler(Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> handler)
Sets the specific hook function.
|
static void |
setInitNewThreadSchedulerHandler(Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> handler)
Sets the specific hook function.
|
static void |
setInitSingleSchedulerHandler(Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> handler)
Sets the specific hook function.
|
static void |
setIoSchedulerHandler(Function<? super Scheduler,? extends Scheduler> handler)
Sets the specific hook function.
|
static void |
setNewThreadSchedulerHandler(Function<? super Scheduler,? extends Scheduler> handler)
Sets the specific hook function.
|
static void |
setOnBeforeBlocking(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.
|
static void |
setOnCompletableAssembly(Function<? super Completable,? extends Completable> onCompletableAssembly)
Sets the specific hook function.
|
static void |
setOnCompletableSubscribe(BiFunction<? super Completable,? super CompletableObserver,? extends CompletableObserver> onCompletableSubscribe)
Sets the specific hook function.
|
static void |
setOnConnectableFlowableAssembly(Function<? super ConnectableFlowable,? extends ConnectableFlowable> onConnectableFlowableAssembly)
Sets the specific hook function.
|
static void |
setOnConnectableObservableAssembly(Function<? super ConnectableObservable,? extends ConnectableObservable> onConnectableObservableAssembly)
Sets the specific hook function.
|
static void |
setOnFlowableAssembly(Function<? super Flowable,? extends Flowable> onFlowableAssembly)
Sets the specific hook function.
|
static void |
setOnFlowableSubscribe(BiFunction<? super Flowable,? super org.reactivestreams.Subscriber,? extends org.reactivestreams.Subscriber> onFlowableSubscribe)
Sets the specific hook function.
|
static void |
setOnMaybeAssembly(Function<? super Maybe,? extends Maybe> onMaybeAssembly)
Sets the specific hook function.
|
static void |
setOnMaybeSubscribe(BiFunction<? super Maybe,MaybeObserver,? extends MaybeObserver> onMaybeSubscribe)
Sets the specific hook function.
|
static void |
setOnObservableAssembly(Function<? super Observable,? extends Observable> onObservableAssembly)
Sets the specific hook function.
|
static void |
setOnObservableSubscribe(BiFunction<? super Observable,? super Observer,? extends Observer> onObservableSubscribe)
Sets the specific hook function.
|
static void |
setOnParallelAssembly(Function<? super ParallelFlowable,? extends ParallelFlowable> handler)
Sets the specific hook function.
|
static void |
setOnSingleAssembly(Function<? super Single,? extends Single> onSingleAssembly)
Sets the specific hook function.
|
static void |
setOnSingleSubscribe(BiFunction<? super Single,? super SingleObserver,? extends SingleObserver> onSingleSubscribe)
Sets the specific hook function.
|
static void |
setScheduleHandler(Function<? super java.lang.Runnable,? extends java.lang.Runnable> handler)
Sets the specific hook function.
|
static void |
setSingleSchedulerHandler(Function<? super Scheduler,? extends Scheduler> handler)
Sets the specific hook function.
|
public static void lockdown()
This allows container-like environments to prevent clients messing with plugins.
public static boolean isLockdown()
public static void setFailOnNonBlockingScheduler(boolean enable)
enable
- enable or disable the featurepublic static boolean isFailOnNonBlockingScheduler()
@Nullable public static Function<? super Scheduler,? extends Scheduler> getComputationSchedulerHandler()
@Nullable public static Consumer<? super java.lang.Throwable> getErrorHandler()
@Nullable public static Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> getInitComputationSchedulerHandler()
@Nullable public static Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> getInitIoSchedulerHandler()
@Nullable public static Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> getInitNewThreadSchedulerHandler()
@Nullable public static Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> getInitSingleSchedulerHandler()
@Nullable public static Function<? super Scheduler,? extends Scheduler> getIoSchedulerHandler()
@Nullable public static Function<? super Scheduler,? extends Scheduler> getNewThreadSchedulerHandler()
@Nullable public static Function<? super java.lang.Runnable,? extends java.lang.Runnable> getScheduleHandler()
@Nullable public static Function<? super Scheduler,? extends Scheduler> getSingleSchedulerHandler()
@NonNull public static Scheduler initComputationScheduler(@NonNull java.util.concurrent.Callable<Scheduler> defaultScheduler)
defaultScheduler
- a Callable
which returns the hook's input valuejava.lang.NullPointerException
- if the callable parameter or its result are null@NonNull public static Scheduler initIoScheduler(@NonNull java.util.concurrent.Callable<Scheduler> defaultScheduler)
defaultScheduler
- a Callable
which returns the hook's input valuejava.lang.NullPointerException
- if the callable parameter or its result are null@NonNull public static Scheduler initNewThreadScheduler(@NonNull java.util.concurrent.Callable<Scheduler> defaultScheduler)
defaultScheduler
- a Callable
which returns the hook's input valuejava.lang.NullPointerException
- if the callable parameter or its result are null@NonNull public static Scheduler initSingleScheduler(@NonNull java.util.concurrent.Callable<Scheduler> defaultScheduler)
defaultScheduler
- a Callable
which returns the hook's input valuejava.lang.NullPointerException
- if the callable parameter or its result are null@NonNull public static Scheduler onComputationScheduler(@NonNull Scheduler defaultScheduler)
defaultScheduler
- the hook's input valuepublic static void onError(@NonNull java.lang.Throwable error)
error
- the error to report@NonNull public static Scheduler onIoScheduler(@NonNull Scheduler defaultScheduler)
defaultScheduler
- the hook's input value@NonNull public static Scheduler onNewThreadScheduler(@NonNull Scheduler defaultScheduler)
defaultScheduler
- the hook's input value@NonNull public static java.lang.Runnable onSchedule(@NonNull java.lang.Runnable run)
run
- the runnable instance@NonNull public static Scheduler onSingleScheduler(@NonNull Scheduler defaultScheduler)
defaultScheduler
- the hook's input valuepublic static void reset()
public static void setComputationSchedulerHandler(@Nullable Function<? super Scheduler,? extends Scheduler> handler)
handler
- the hook function to set, null allowedpublic static void setErrorHandler(@Nullable Consumer<? super java.lang.Throwable> handler)
handler
- the hook function to set, null allowedpublic static void setInitComputationSchedulerHandler(@Nullable Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> handler)
handler
- the hook function to set, null allowed, but the function may not return nullpublic static void setInitIoSchedulerHandler(@Nullable Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> handler)
handler
- the hook function to set, null allowed, but the function may not return nullpublic static void setInitNewThreadSchedulerHandler(@Nullable Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> handler)
handler
- the hook function to set, null allowed, but the function may not return nullpublic static void setInitSingleSchedulerHandler(@Nullable Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> handler)
handler
- the hook function to set, null allowed, but the function may not return nullpublic static void setIoSchedulerHandler(@Nullable Function<? super Scheduler,? extends Scheduler> handler)
handler
- the hook function to set, null allowedpublic static void setNewThreadSchedulerHandler(@Nullable Function<? super Scheduler,? extends Scheduler> handler)
handler
- the hook function to set, null allowedpublic static void setScheduleHandler(@Nullable Function<? super java.lang.Runnable,? extends java.lang.Runnable> handler)
handler
- the hook function to set, null allowedpublic static void setSingleSchedulerHandler(@Nullable Function<? super Scheduler,? extends Scheduler> handler)
handler
- the hook function to set, null allowed@Nullable public static Function<? super Completable,? extends Completable> getOnCompletableAssembly()
@Nullable public static BiFunction<? super Completable,? super CompletableObserver,? extends CompletableObserver> getOnCompletableSubscribe()
@Nullable public static Function<? super Flowable,? extends Flowable> getOnFlowableAssembly()
@Nullable public static Function<? super ConnectableFlowable,? extends ConnectableFlowable> getOnConnectableFlowableAssembly()
@Nullable public static BiFunction<? super Flowable,? super org.reactivestreams.Subscriber,? extends org.reactivestreams.Subscriber> getOnFlowableSubscribe()
@Nullable public static BiFunction<? super Maybe,? super MaybeObserver,? extends MaybeObserver> getOnMaybeSubscribe()
@Nullable public static Function<? super Maybe,? extends Maybe> getOnMaybeAssembly()
@Nullable public static Function<? super Single,? extends Single> getOnSingleAssembly()
@Nullable public static BiFunction<? super Single,? super SingleObserver,? extends SingleObserver> getOnSingleSubscribe()
@Nullable public static Function<? super Observable,? extends Observable> getOnObservableAssembly()
@Nullable public static Function<? super ConnectableObservable,? extends ConnectableObservable> getOnConnectableObservableAssembly()
@Nullable public static BiFunction<? super Observable,? super Observer,? extends Observer> getOnObservableSubscribe()
public static void setOnCompletableAssembly(@Nullable Function<? super Completable,? extends Completable> onCompletableAssembly)
onCompletableAssembly
- the hook function to set, null allowedpublic static void setOnCompletableSubscribe(@Nullable BiFunction<? super Completable,? super CompletableObserver,? extends CompletableObserver> onCompletableSubscribe)
onCompletableSubscribe
- the hook function to set, null allowedpublic static void setOnFlowableAssembly(@Nullable Function<? super Flowable,? extends Flowable> onFlowableAssembly)
onFlowableAssembly
- the hook function to set, null allowedpublic static void setOnMaybeAssembly(@Nullable Function<? super Maybe,? extends Maybe> onMaybeAssembly)
onMaybeAssembly
- the hook function to set, null allowedpublic static void setOnConnectableFlowableAssembly(@Nullable Function<? super ConnectableFlowable,? extends ConnectableFlowable> onConnectableFlowableAssembly)
onConnectableFlowableAssembly
- the hook function to set, null allowedpublic static void setOnFlowableSubscribe(@Nullable BiFunction<? super Flowable,? super org.reactivestreams.Subscriber,? extends org.reactivestreams.Subscriber> onFlowableSubscribe)
onFlowableSubscribe
- the hook function to set, null allowedpublic static void setOnMaybeSubscribe(@Nullable BiFunction<? super Maybe,MaybeObserver,? extends MaybeObserver> onMaybeSubscribe)
onMaybeSubscribe
- the hook function to set, null allowedpublic static void setOnObservableAssembly(@Nullable Function<? super Observable,? extends Observable> onObservableAssembly)
onObservableAssembly
- the hook function to set, null allowedpublic static void setOnConnectableObservableAssembly(@Nullable Function<? super ConnectableObservable,? extends ConnectableObservable> onConnectableObservableAssembly)
onConnectableObservableAssembly
- the hook function to set, null allowedpublic static void setOnObservableSubscribe(@Nullable BiFunction<? super Observable,? super Observer,? extends Observer> onObservableSubscribe)
onObservableSubscribe
- the hook function to set, null allowedpublic static void setOnSingleAssembly(@Nullable Function<? super Single,? extends Single> onSingleAssembly)
onSingleAssembly
- the hook function to set, null allowedpublic static void setOnSingleSubscribe(@Nullable BiFunction<? super Single,? super SingleObserver,? extends SingleObserver> onSingleSubscribe)
onSingleSubscribe
- the hook function to set, null allowed@NonNull public static <T> org.reactivestreams.Subscriber<? super T> onSubscribe(@NonNull Flowable<T> source, @NonNull org.reactivestreams.Subscriber<? super T> subscriber)
T
- the value typesource
- the hook's input valuesubscriber
- the subscriber@NonNull public static <T> Observer<? super T> onSubscribe(@NonNull Observable<T> source, @NonNull Observer<? super T> observer)
T
- the value typesource
- the hook's input valueobserver
- the observer@NonNull public static <T> SingleObserver<? super T> onSubscribe(@NonNull Single<T> source, @NonNull SingleObserver<? super T> observer)
T
- the value typesource
- the hook's input valueobserver
- the observer@NonNull public static CompletableObserver onSubscribe(@NonNull Completable source, @NonNull CompletableObserver observer)
source
- the hook's input valueobserver
- the observer@NonNull public static <T> MaybeObserver<? super T> onSubscribe(@NonNull Maybe<T> source, @NonNull MaybeObserver<? super T> subscriber)
T
- the value typesource
- the hook's input valuesubscriber
- the subscriber@NonNull public static <T> Maybe<T> onAssembly(@NonNull Maybe<T> source)
T
- the value typesource
- the hook's input value@NonNull public static <T> Flowable<T> onAssembly(@NonNull Flowable<T> source)
T
- the value typesource
- the hook's input value@NonNull public static <T> ConnectableFlowable<T> onAssembly(@NonNull ConnectableFlowable<T> source)
T
- the value typesource
- the hook's input value@NonNull public static <T> Observable<T> onAssembly(@NonNull Observable<T> source)
T
- the value typesource
- the hook's input value@NonNull public static <T> ConnectableObservable<T> onAssembly(@NonNull ConnectableObservable<T> source)
T
- the value typesource
- the hook's input value@NonNull public static <T> Single<T> onAssembly(@NonNull Single<T> source)
T
- the value typesource
- the hook's input value@NonNull public static Completable onAssembly(@NonNull Completable source)
source
- the hook's input valuepublic static void setOnParallelAssembly(@Nullable Function<? super ParallelFlowable,? extends ParallelFlowable> handler)
handler
- the hook function to set, null allowed@Nullable public static Function<? super ParallelFlowable,? extends ParallelFlowable> getOnParallelAssembly()
@NonNull public static <T> ParallelFlowable<T> onAssembly(@NonNull ParallelFlowable<T> source)
T
- the value type of the sourcesource
- the hook's input valuepublic static boolean onBeforeBlocking()
setFailOnNonBlockingScheduler(boolean)
public static void setOnBeforeBlocking(@Nullable BooleanSupplier handler)
handler
- the handler to set, null resets to the default handler
that always returns falseonBeforeBlocking()
@Nullable public static BooleanSupplier getOnBeforeBlocking()
@NonNull public static Scheduler createComputationScheduler(@NonNull java.util.concurrent.ThreadFactory threadFactory)
Scheduler
used for Schedulers.computation()
except using threadFactory
for thread creation.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.@NonNull public static Scheduler createIoScheduler(@NonNull java.util.concurrent.ThreadFactory threadFactory)
Scheduler
used for Schedulers.io()
except using threadFactory
for thread creation.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.@NonNull public static Scheduler createNewThreadScheduler(@NonNull java.util.concurrent.ThreadFactory threadFactory)
Scheduler
used for Schedulers.newThread()
except using threadFactory
for thread creation.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.@NonNull public static Scheduler createSingleScheduler(@NonNull java.util.concurrent.ThreadFactory threadFactory)
Scheduler
used for Schedulers.single()
except using threadFactory
for thread creation.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.