Fudge
04/18/2025, 7:49 PMclass SomeStateObject<T>(
var someValue: T
)
Now we want to make someValue
react to state changes. So we can do something like this:
class WithComposeReaction<T>(
someValue:T
){
var someValue = mutableStateOf(someValue)
}
But now we need to declare every field like this twice. Java-esque.
So another way is doing this:
class WithComposeReaction<T>(
someValue: MutableState<T>
)
But that fucks up the constructor API.
Finally, we can forego some type safety and arrive at this
class WithComposeReaction<T> {
var someValue: T? by mutableStateOf(null)
}
And then we change someValue
after construction.
No solution is very good 😕
So I'm wondering, do you have any creative approaches to solve this?gildor
04/21/2025, 5:01 AMmattinger
04/21/2025, 2:31 PMclass WithComposeReaction<T>(
initialValue:T
) {
var someValue by mutableStateOf(initialValue)
}