I have a (quite) complex composable compound of se...
# compose
o
I have a (quite) complex composable compound of several pieces modifying a common state. I'd like to avoid giving plenty of callbacks everywhere in favor of centralizing such logic in a "state" object consumed by all my composables. I can't make it work so far. I think I read somewhere how to deal with that, to avoid tons of
value, onValueChanged: () -> Unit
, extract it in a "state". Does it ring a bell to someone? Any advice on how to manage my use case? (I can detail more if needed)
r
Can you pass the
MutableState
that
mutableStateOf
returns? Or if you have a more complex state, create a class with properties backed by
mutableStateOf
.
👍 1
o
I used the first approach yes but didn't feel like a good one 🤷‍♂️ (I don't think we use this with built in composable). Initially, I was exposing simple
var
on my custom state and I came to the same conclusion than yours, I should expose
State
from such custom state class.
I don't know if it's what I saw on the article I was looking for but seems to properly encapsulate things at least 👍