public static class PrimeBuilder.ChangesBuilder<State,Change,Action>
A configuration builder for Change related declarations.
| Modifier and Type | Method and Description |
|---|---|
Effect<State,Action> |
getOnly(State $receiver)
Turns State into an
class Effect without Action. |
io.reactivex.Scheduler |
getWatchOn()
An optional Scheduler used for watching Changes.
|
Effect.WithAction<State,Action> |
plus(State $receiver,
Action action)
Combines State and Action into
class Effect. |
void |
reduce(kotlin.reflect.KClass<? extends Change> changeType,
kotlin.jvm.functions.Function2<? super State,? super Change,? extends de.halfbit.knot.Effect<State,Action>> reduce)
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 |
setWatchOn(io.reactivex.Scheduler value)
An optional Scheduler used for watching Changes.
|
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 getWatchOn()
An optional Scheduler used for watching Changes.
public void setWatchOn(io.reactivex.Scheduler value)
An optional Scheduler used for watching Changes.
public void reduce(kotlin.reflect.KClass<? extends Change> changeType,
kotlin.jvm.functions.Function2<? super State,? super Change,? extends de.halfbit.knot.Effect<State,Action>> reduce)
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 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.WithAction<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.