Jetpack Compose is Android’s new declarative UI Framework.
Jetpack Compose is built around composable functions. These functions let you define your app’s UI programmatically by describing how it should look and providing data dependencies, rather than focusing on the process of the UI’s construction (initializing an element, attaching it to a parent, etc.). To create a composable function, just add the @Composable
annotation to the function name.
Composition is the process in which your Composable functions are executed and the UI is created for the user.
Recomposition is the process of updating the UI as a result of a State or Data Change that a Composable is using for its display. During recomposition, Compose is able to understand which data each Composable uses and only updates the UI components that have changed. The rest of the Composables are skipped.
Composable functions can execute in any order: If a composable function contains calls to other composable functions, those functions might run in any order. Compose has the option of recognizing that some UI elements are higher priority than others, and drawing them first.
Composable functions can run in parallel: Compose can optimize recomposition by running composable functions in parallel. This optimization means a composable function might execute within a pool of background threads. If a composable function calls a function on a ViewModel
, Compose might call that function from several threads at the same time.