Composing and recomposing the UI
Unlike imperative UI frameworks, Jetpack Compose does not depend on the developer proactively modifying a component tree when changes in the app data require changes to be made to the UI. Instead, Jetpack Compose detects such changes on its own and updates only the affected parts.
As you know by now, a Compose UI is declared based on the current app data. In my previous examples, you have seen quite a few conditional expressions (such as
when) that determine which composable function is called or which parameters it receives. So, we are describing the complete UI in our code. The branch that will be executed depends on the app data (state) during runtime. The Web framework that React has a similar concept called Virtual DOM. But doesn't this contradict with me saying Compose detects such changes on its own and updates only the affected parts?
Conceptually, Jetpack Compose regenerates the entire UI when changes need to be applied. This...