I have a variable that is remembered in code
val action = remember { mutableStateOf(Action.FRESH) }
action can have values of (FRESH, SEARCH, IDLE)
I want to avoid recomposition if action changed to Action.IDLE, but recompose normally for any other value..
I read the action value as follows:
val listOfItems = when (action) {
Action.FRESH -> {
action = Action.IDLE
// Get Initial data from server
}
Action.SEARCH -> {
action = Action.IDLE
// Get Search data from server
}
else -> {
// Do Nothing
}
}
I don't want to recompose when action is IDLE so I won't have to set listOfItems with a empty value in the else branch...
I tried adding key to remember and also using derivedStateOf but nothing worked as expected.
Any ideas?