martinsumera
03/09/2021, 3:30 PMval backCallback = remember { /* ... */ }
SideEffect {
backCallback.isEnabled = enabled
}
and
val backCallback = remember { /* ... */ }
backCallback.isEnabled = enabled
Adam Powell
03/09/2021, 3:33 PMbackCallback
is not a Compose-aware object and should not be mutated during composition. The SideEffect
API is a way to defer these kinds of side effects until the composition has successfully been applied, and side effects are executed on the main thread, whereas composition may happen on other threads.mutableStateOf
objects) but it's generally much harder to do this for objects that weren't written to work with ComposeSideEffect
to defer the operation until the composition is applied instead, when there's no potential need to roll back/discard the composition pass anymore.martinsumera
03/09/2021, 3:42 PM