May 2022
Intermediate to advanced
688 pages
20h 12m
English
Compared to your work in the framework UI toolkit to keep your app state and UI state in sync, Compose’s automatic UI updates could seem a bit magical. Allow us to dispel some of the magic.
To see how Compose updates your UI firsthand, add a log statement to your ToppingCell composable to print a message each time the function is invoked.
Listing 27.7 Pulling back the curtain (ToppingCell.kt)
...
@Composable
fun ToppingCell(
topping: Topping,
placement: ToppingPlacement?,
onClickTopping: () -> Unit,
modifier: Modifier = Modifier
) {
Log.d("ToppingCell", "Called ToppingCell for $topping")
Row(
...
) {
...
}
}
Run Coda Pizza and open Logcat. Right after Coda Pizza starts, you will see that your new log message ...
Read now
Unlock full access