public static class RxMobius.SubtypeEffectHandlerBuilder<F,E>
extends java.lang.Object
Register handlers for different subtypes of F using the add(...) methods, and call build() to create an instance of the effect handler. You can then create a loop with the
router as the effect handler using RxMobius.loop(Update, Observable.Transformer).
The handler will look at the type of each incoming effect object and try to find a registered handler for that particular subtype of F. If a handler is found, it will be given the effect object, otherwise an exception will be thrown.
All the classes that the effect router know about must have a common type F. Note that instances of the builder are mutable and not thread-safe.
| Modifier and Type | Method and Description |
|---|---|
<G extends F> |
add(java.lang.Class<G> effectClass,
rx.functions.Action0 action)
Deprecated.
|
<G extends F> |
add(java.lang.Class<G> effectClass,
rx.functions.Action0 action,
rx.Scheduler scheduler)
Deprecated.
|
<G extends F> |
add(java.lang.Class<G> effectClass,
rx.functions.Action1<G> action)
Deprecated.
|
<G extends F> |
add(java.lang.Class<G> effectClass,
rx.functions.Action1<G> action,
rx.Scheduler scheduler)
Deprecated.
|
<G extends F> |
add(java.lang.Class<G> effectClass,
rx.Observable.Transformer<G,E> effectHandler)
Deprecated.
use
#addTransformer(Class, Transformer) |
<G extends F> |
addAction(java.lang.Class<G> effectClass,
rx.functions.Action0 action)
Add an
Action0 for handling effects of a given type. |
<G extends F> |
addAction(java.lang.Class<G> effectClass,
rx.functions.Action0 action,
rx.Scheduler scheduler)
Add an
Action0 for handling effects of a given type. |
<G extends F> |
addConsumer(java.lang.Class<G> effectClass,
rx.functions.Action1<G> consumer)
Add an
Action1 for handling effects of a given type. |
<G extends F> |
addConsumer(java.lang.Class<G> effectClass,
rx.functions.Action1<G> consumer,
rx.Scheduler scheduler)
Add an
Action1 for handling effects of a given type. |
<G extends F> |
addFunction(java.lang.Class<G> effectClass,
com.spotify.mobius.functions.Function<G,E> function)
Add a
Func1 for handling effects of a given type. |
<G extends F> |
addFunction(java.lang.Class<G> effectClass,
com.spotify.mobius.functions.Function<G,E> function,
rx.Scheduler scheduler)
Add a
Func1 for handling effects of a given type. |
<G extends F> |
addTransformer(java.lang.Class<G> effectClass,
rx.Observable.Transformer<G,E> effectHandler)
Add an
Observable.Transformer for handling effects of a given type. |
rx.Observable.Transformer<F,E> |
build() |
RxMobius.SubtypeEffectHandlerBuilder<F,E> |
withFatalErrorHandler(rx.functions.Func1<rx.Observable.Transformer<? extends F,E>,rx.functions.Action1<java.lang.Throwable>> onErrorFunction)
Optionally set a shared error handler in case a handler throws an uncaught exception.
|
@Deprecated public <G extends F> RxMobius.SubtypeEffectHandlerBuilder<F,E> add(java.lang.Class<G> effectClass, rx.Observable.Transformer<G,E> effectHandler)
#addTransformer(Class, Transformer)Observable.Transformer for handling effects of a given type. The handler will
receive all effect objects that extend the given class.
Adding handlers for two effect classes where one is a super-class of the other is considered a collision and is not allowed. Registering the same class twice is also considered a collision.
G - the effect class as a type parametereffectClass - the effect class to handleeffectHandler - the effect handler for the given effect classjava.lang.IllegalArgumentException - if there is a handler collision@Deprecated public <G extends F> RxMobius.SubtypeEffectHandlerBuilder<F,E> add(java.lang.Class<G> effectClass, rx.functions.Action0 action)
addAction(Class, Action0)Action0 for handling effects of a given type. The action will be invoked once
for every received effect object that extends the given class.
Adding handlers for two effect classes where one is a super-class of the other is considered a collision and is not allowed. Registering the same class twice is also considered a collision.
G - the effect class as a type parametereffectClass - the class to handleaction - the action that should be invoked for the effectjava.lang.IllegalArgumentException - if there is a handler collision@Deprecated public <G extends F> RxMobius.SubtypeEffectHandlerBuilder<F,E> add(java.lang.Class<G> effectClass, rx.functions.Action0 action, rx.Scheduler scheduler)
addAction(Class, Action0, Scheduler)Action0 for handling effects of a given type. The action will be invoked once
for every received effect object that extends the given class.
Adding handlers for two effect classes where one is a super-class of the other is considered a collision and is not allowed. Registering the same class twice is also considered a collision.
G - the effect class as a type parametereffectClass - the class to handleaction - the action that should be invoked for the effectscheduler - the scheduler that should be used to invoke the actionjava.lang.IllegalArgumentException - if there is a handler collision@Deprecated public <G extends F> RxMobius.SubtypeEffectHandlerBuilder<F,E> add(java.lang.Class<G> effectClass, rx.functions.Action1<G> action)
addConsumer(Class, Action1)Action1 for handling effects of a given type. The action will be invoked once
for every received effect object that extends the given class.
Adding handlers for two effect classes where one is a super-class of the other is considered a collision and is not allowed. Registering the same class twice is also considered a collision.
G - the effect class as a type parametereffectClass - the class to handleaction - the action that should be invoked for the effectjava.lang.IllegalArgumentException - if there is a handler collision@Deprecated public <G extends F> RxMobius.SubtypeEffectHandlerBuilder<F,E> add(java.lang.Class<G> effectClass, rx.functions.Action1<G> action, rx.Scheduler scheduler)
addConsumer(Class, Action1, Scheduler)Action1 for handling effects of a given type. The action will be invoked once
for every received effect object that extends the given class.
Adding handlers for two effect classes where one is a super-class of the other is considered a collision and is not allowed. Registering the same class twice is also considered a collision.
G - the effect class as a type parametereffectClass - the class to handleaction - the action that should be invoked for the effectscheduler - the scheduler that should be used to invoke the actionjava.lang.IllegalArgumentException - if there is a handler collisionpublic <G extends F> RxMobius.SubtypeEffectHandlerBuilder<F,E> addFunction(java.lang.Class<G> effectClass, com.spotify.mobius.functions.Function<G,E> function)
Func1 for handling effects of a given type. The function will be invoked once
for every received effect object that extends the given class. The returned event will be
forwarded to the Mobius loop.
Adding handlers for two effect classes where one is a super-class of the other is considered a collision and is not allowed. Registering the same class twice is also considered a collision.
G - the effect class as a type parametereffectClass - the class to handlefunction - the function that should be invoked for the effectjava.lang.IllegalArgumentException - if there is a handler collisionpublic <G extends F> RxMobius.SubtypeEffectHandlerBuilder<F,E> addFunction(java.lang.Class<G> effectClass, com.spotify.mobius.functions.Function<G,E> function, rx.Scheduler scheduler)
Func1 for handling effects of a given type. The function will be invoked once
for every received effect object that extends the given class. The returned event will be
forwarded to the Mobius loop.
Adding handlers for two effect classes where one is a super-class of the other is considered a collision and is not allowed. Registering the same class twice is also considered a collision.
G - the effect class as a type parametereffectClass - the class to handlefunction - the function that should be invoked for the effectscheduler - the scheduler that should be used when invoking the functionjava.lang.IllegalArgumentException - if there is a handler collisionpublic <G extends F> RxMobius.SubtypeEffectHandlerBuilder<F,E> addTransformer(java.lang.Class<G> effectClass, rx.Observable.Transformer<G,E> effectHandler)
Observable.Transformer for handling effects of a given type. The handler will
receive all effect objects that extend the given class.
Adding handlers for two effect classes where one is a super-class of the other is considered a collision and is not allowed. Registering the same class twice is also considered a collision.
G - the effect class as a type parametereffectClass - the effect class to handleeffectHandler - the effect handler for the given effect classjava.lang.IllegalArgumentException - if there is a handler collisionpublic <G extends F> RxMobius.SubtypeEffectHandlerBuilder<F,E> addAction(java.lang.Class<G> effectClass, rx.functions.Action0 action)
Action0 for handling effects of a given type. The action will be invoked once
for every received effect object that extends the given class.
Adding handlers for two effect classes where one is a super-class of the other is considered a collision and is not allowed. Registering the same class twice is also considered a collision.
G - the effect class as a type parametereffectClass - the class to handleaction - the action that should be invoked for the effectjava.lang.IllegalArgumentException - if there is a handler collisionpublic <G extends F> RxMobius.SubtypeEffectHandlerBuilder<F,E> addAction(java.lang.Class<G> effectClass, rx.functions.Action0 action, rx.Scheduler scheduler)
Action0 for handling effects of a given type. The action will be invoked once
for every received effect object that extends the given class.
Adding handlers for two effect classes where one is a super-class of the other is considered a collision and is not allowed. Registering the same class twice is also considered a collision.
G - the effect class as a type parametereffectClass - the class to handleaction - the action that should be invoked for the effectscheduler - the scheduler that should be used to invoke the actionjava.lang.IllegalArgumentException - if there is a handler collisionpublic <G extends F> RxMobius.SubtypeEffectHandlerBuilder<F,E> addConsumer(java.lang.Class<G> effectClass, rx.functions.Action1<G> consumer)
Action1 for handling effects of a given type. The action will be invoked once
for every received effect object that extends the given class.
Adding handlers for two effect classes where one is a super-class of the other is considered a collision and is not allowed. Registering the same class twice is also considered a collision.
G - the effect class as a type parametereffectClass - the class to handleconsumer - the consumer that should be invoked for the effectjava.lang.IllegalArgumentException - if there is a handler collisionpublic <G extends F> RxMobius.SubtypeEffectHandlerBuilder<F,E> addConsumer(java.lang.Class<G> effectClass, rx.functions.Action1<G> consumer, rx.Scheduler scheduler)
Action1 for handling effects of a given type. The action will be invoked once
for every received effect object that extends the given class.
Adding handlers for two effect classes where one is a super-class of the other is considered a collision and is not allowed. Registering the same class twice is also considered a collision.
G - the effect class as a type parametereffectClass - the class to handleconsumer - the consumer that should be invoked for the effectscheduler - the scheduler that should be used to invoke the actionjava.lang.IllegalArgumentException - if there is a handler collisionpublic RxMobius.SubtypeEffectHandlerBuilder<F,E> withFatalErrorHandler(rx.functions.Func1<rx.Observable.Transformer<? extends F,E>,rx.functions.Action1<java.lang.Throwable>> onErrorFunction)
The default is to use RxJavaHooks.onError(Throwable). Note that any exception
thrown by a handler is a fatal error and this method doesn't enable safe error handling, only
configurable crash reporting.
onErrorFunction - a function that gets told which sub-transformer failed and should
return an appropriate handler for exceptions thrown.