LoggingReducer before and after state #35
Answered
by
xOIBrandon
xOIBrandon
asked this question in
Q&A
-
I have a LoggingReducer similar to the one in the example in the README.md. I was wondering if it was possible to access the newly updated state, after its been mutated by the reducer? class LoggingReducer(
val environment: AppEnvironment,
private val innerReducer: Reducer<AppState, AppAction>
) : Reducer<AppState, AppAction> {
override fun reduce(
state: Mutable<AppState>,
action: AppAction
): List<Effect<AppAction>> {
environment.log.d("starting state ${json.encodeToString(state.invoke())}")
environment.log.d("$action")
innerReducer.reduce(state, action)
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
xOIBrandon
Sep 2, 2022
Replies: 1 comment
-
NM - i seem to have answered my own question class LoggingReducer(
val environment: AppEnvironment,
private val innerReducer: Reducer<AppState, AppAction>
) : Reducer<AppState, AppAction> {
override fun reduce(
state: Mutable<AppState>,
action: AppAction
): List<Effect<AppAction>> {
environment.log.d("starting state ${state.invoke()}")
val effects = innerReducer.reduce(state, action)
environment.log.d("ending state ${state.invoke()}")
return effects
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
xOIBrandon
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NM - i seem to have answered my own question