Slide 32
Slide 32 text
R
Fe
class SimpleFeature : ReducerFeature(
initialState = State(),
reducer = ReducerImpl()
) {
data class State(
val counter: Int = 0,
val someText: String = ""
)£
sealed class Wish {
object IncreaseCounter : Wish()
data class SetText(val text: String) : Wish()
}•
class ReducerImpl : Reducer {
override fun invoke(state: State, wish: Wish): State =
when (wish) {
IncreaseCounter -> state.copy(
counter = state.counter + 1
)§
is SetText -> state.copy(
someText = wish.text
)¡
}™
}¢
}