-
-
Notifications
You must be signed in to change notification settings - Fork 80
Improve working with sealed class states #197
Copy link
Copy link
Closed
Description
Currently, working with states that are sealed classes requires lots of casting. Investigate if we can create a DSL that would help this.
Primary things to figure out:
- What happens if the state does not match the expected type?
- Crash or fail silently
- What should be the default here
- Should this behaviour be controllable?
Some random thoughts of how we could help by adding new DSL methods
private fun setExampleDataIntent() = intentForState<ExampleState.Success> {
reduce {
state.copy(
firstName = "John",
lastName = "Doe",
age = 18
)
}
println(state.age) // 18
}
OR
private fun setExampleDataIntent() = intent {
withSubstate<ExampleState.Success>(throwOnMismatch=true) {
reduce {
state.copy(
firstName = "John",
lastName = "Doe",
age = 18
)
}
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done