Hi everyone, I am trying to update mutablestate va...
# android
a
Hi everyone, I am trying to update mutablestate value in another compose but I found that it is not recommended. I know I can use lambda expression and update mutablestate value in ShowCases compose but in such cases I don't want to use that solution. What is the proper way to do that? (some explanation about that issue https://medium.com/mobile-app-development-publication/how-kotlin-by-variable-delegate-helps-me-avoid-anti-pattern-558004000341 )
@Composable
fun ShowCases(){
*val* isChecked *= remember {* mutableStateOf*(false) }*
*MyCompose(*isChecked *=* isChecked*)*
}
@Composable
*fun MyCompose(*isChecked:*MutableState<Boolean>){*
*Switch(*checked *= isChecked.*value*,*
onCheckedChange *= {isChecked.*value *= it})*
}
k
“I know I can use lambda expression and update mutablestate value in ShowCases compose but in such cases I don’t want to use that solution.” • why not?
a
for example when user swipe the view and click the item, I close(collapse) the view for user in the repo https://github.com/akardas16/SwipeActions To do that I need to change isExpand mutablestate value from user in my SwipeActionRight compose
I used viewmodel observe for that because of that issue
v
That library and its SwipeActionsRight exact #1 reason to not couple composables with view models. Just hoist data/callbacks
👍 2