Chapter 7: Tips, Tricks, and Best Practices
In Chapter 6, Putting Pieces Together, we combined several key techniques of Jetpack Compose such as state hoisting, app theming, and navigation in a real-world example. ComposeUnitConverter stores state in a ViewModel and eventually persists it using the Repository pattern. In this chapter, I show you how to pass objects to a ViewModel upon instantiation and use these objects to load and save data. In Chapter 3, Exploring the Key Principles of Compose, we examined features of well-behaved composable functions. Composables should be free of side effects to make them reusable and easy to test. However, there are situations when you need to either react to or initiate state changes that happen outside ...
Get Android UI Development with Jetpack Compose now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.