Archie
07/29/2020, 3:25 PMKotlin Redux
a few days back and now Im starting to learn and study it. I understand the concepts very well but I just can't get how to model the AppState
right.
How exactly do you model the AppState
? Examples I've seen so far only show a small application where the AppState
is very simple. But how do you model an AppState
in a Large Application with multiple screens? Do I make smaller "`AppState`" inside the "root" AppState
like:
data class AppState(
val loginAppState: LoginAppState,
val signUpAppState: SignUpAppState
val someOtherScreenAppState: OtherScreenAppState
....
)
data class LoginAppState(
val usernamer: String,
val password: String
....
)
It seems that Redux
makes sense when screens share state between screens such as the Todo Application Example or its very simple when dealing with single screen application such as the Counter Application but how do you model the AppState
when working with screens doesn't really have connected state such as an application with a LoginScreen
and SignUpScreen
. Those two screens doesn't share any state. How to deal with these kinds of scenarios?
I'd really appreciate any help. Thank you very much in advancewillyrs
07/29/2020, 3:50 PMGeorge Theocharis
07/30/2020, 10:39 AMArchie
07/30/2020, 10:48 AMAppState
I will also have to manage when those `State`s get cleaned up. So in a SignUpScreen
where you have User details, once the User is logged-in or have moved out of the SignUpScreen I would need to have an Action
which would be interpreted by a reducer to clear the state. Is that correct?George Theocharis
07/30/2020, 11:03 AMwillyrs
07/30/2020, 11:06 AMArchie
07/30/2020, 11:19 AMwillyrs
07/30/2020, 11:24 AMArchie
07/30/2020, 11:29 AMdata class AppState(
val someState: SomeState = reducerSomeState(action),
val someState: SomeState = reducerAnotherState(action)
....
)
// I cant imagine how to do it for the state inside the substate
data class SomeState(
val somthing: String = reducerSomething(action)
....
willyrs
07/30/2020, 11:29 AMArchie
07/30/2020, 11:30 AMwillyrs
07/30/2020, 11:31 AMArchie
07/30/2020, 11:31 AMHomeState
I was wondering how you'd scale it once HomeState
gets bigger.willyrs
07/30/2020, 1:35 PMArchie
07/30/2020, 1:36 PMfun homeReducer(state: HomeState, action: Any): HomeState {
return HomeState(
latest = reduceHomeLatest(action),
something = reduceSomething(action),
....
)
}
willyrs
07/30/2020, 1:37 PMpatjackson52
08/07/2020, 3:41 PM