You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a proposal to switch to using sealed classes, data classes and objects to represent intents.
Currently we are exposing multiple functions from our view models to our views to represent actions
classMyLoginViewModel : AndroidDataFlow()
funlogin(mobileNumber:String, code:String) = action {
// Manipulate state
}
funresendCode(mobileNumber:String) = action {
// Manipulate state
}
}
// In our view
viewModel.login(mobileNumber, code)
viewModel.resendCode(mobileNumber)
Recently in projects I have been using this approach to have fewer public functions and use sealed classes for intents and handle the intents in an exhaustive way.
sealedclassMyLoginIntent {
data classLogin(mobileNumber:String, code:String) : MyLoginIntent()
data classResendCode(mobileNumber:String) : MyLoginIntent()
}
classMyLoginViewModel : AndroidDataFlow()
funonAction(intent:MyLoginIntent) = action {
when(intent) {
isMyLoginIntent.Login-> login(intent)
isMyLoginIntent.ResendCode-> resendCode(intent)
}
}
privatesuspendfunlogin(loginIntent:MyLoginIntent.Login) {
// Manipulate state
}
privatesuspendfunresendCode(resendCodeIntent:MyLoginIntent.ResendCode) {
// Manipulate state
}
}
// In our view
viewModel.onAction(MyLoginIntent.Login(mobileNumber, code)
viewModel.onAction(MyLoginIntent.ResendCode(mobileNumber)
Currently Uniflow is taking care of manipulating and representing state in an exhaustive self documenting way. It is taking care of the flow of state but not really taking care of the flow of intents. What do you think of making this pattern part of Uniflow in some way.
The text was updated successfully, but these errors were encountered:
While I like the idea of encapsulating related things and keeping APIs minimal, I think this would add slightly more complexity/code and especially prevent different usages of action and actionOn, right?
Hey
I have a proposal to switch to using sealed classes, data classes and objects to represent intents.
Currently we are exposing multiple functions from our view models to our views to represent actions
Recently in projects I have been using this approach to have fewer public functions and use sealed classes for intents and handle the intents in an exhaustive way.
Currently Uniflow is taking care of manipulating and representing state in an exhaustive self documenting way. It is taking care of the flow of state but not really taking care of the flow of intents. What do you think of making this pattern part of Uniflow in some way.
The text was updated successfully, but these errors were encountered: