public static class KnotBuilder.ChangesBuilder<State,Change,Action>
| Modifier and Type | Method and Description |
|---|---|
Effect<State,Action> |
getOnly(State $receiver)
Turns State into an
class Effect without Action. |
io.reactivex.Scheduler |
getReduceOn()
An optional Scheduler used for reduce function.
|
void |
intercept(kotlin.jvm.functions.Function1<? super io.reactivex.Observable<Change>,? extends io.reactivex.Observable<Change>> interceptor)
A function for intercepting Change emissions.
|
Effect<State,Action> |
plus(State $receiver,
Action action)
Combines State and Action into
class Effect. |
void |
reduce(kotlin.jvm.functions.Function2<? super State,? super Change,de.halfbit.knot.Effect> reducer)
Mandatory reduce function which receives the current State and a Change
and must return
class Effect with a new State and an optional Action. |
void |
setReduceOn(io.reactivex.Scheduler p)
An optional Scheduler used for reduce function.
|
java.lang.Void |
unexpected(State $receiver,
Change change)
Throws IllegalStateException with current State and given Change in its message.
|
void |
watchAll(kotlin.jvm.functions.Function1<? super Change,kotlin.Unit> watcher)
A function for watching Change emissions.
|
public io.reactivex.Scheduler getReduceOn()
An optional Scheduler used for reduce function.
public void setReduceOn(io.reactivex.Scheduler p)
An optional Scheduler used for reduce function.
public void reduce(kotlin.jvm.functions.Function2<? super State,? super Change,de.halfbit.knot.Effect> reducer)
Mandatory reduce function which receives the current State and a Change
and must return class Effect with a new State and an optional Action.
New State and Action can be joined together using overloaded State.plus
operator. For returning State without action call .only on the state.
Example:
changes {
reduce { change ->
when (change) {
is Change.Load -> copy(value = "loading") + Action.Load
is Change.Load.Success -> copy(value = change.payload).only
is Change.Load.Failure -> copy(value = "failed").only
}
}
}
class Effect,
State.pluspublic void intercept(kotlin.jvm.functions.Function1<? super io.reactivex.Observable<Change>,? extends io.reactivex.Observable<Change>> interceptor)
A function for intercepting Change emissions.
public void watchAll(kotlin.jvm.functions.Function1<? super Change,kotlin.Unit> watcher)
A function for watching Change emissions.
public Effect<State,Action> getOnly(State $receiver)
Turns State into an class Effect without Action.
class Effectpublic Effect<State,Action> plus(State $receiver, Action action)
Combines State and Action into class Effect.
class Effectpublic java.lang.Void unexpected(State $receiver,
Change change)
Throws IllegalStateException with current State and given Change in its message.