If you find yourself doing
var someValue by remember { mutableStateOf("") }
often and repeated enough to where it gets onerous or noisy to read, it's often a sign that you want to create a class to hold several observable properties as part of one concept, e.g.
class MyState(
foo: Foo,
bar: Bar
) {
var foo by mutableStateOf(foo)
var bar by mutableStateOf(bar)
private set
}
and use it with a single
remember
, potentially as part of a default argument expression to allow the state to be hoisted to the caller:
@Composable fun MyComposable(
state: MyState = remember { MyState(defaultFoo, defaultBar) }
) {