android / sunflower

A gardening app illustrating Android development best practices with migrating a View-based app to Jetpack Compose.
https://d.android.com/jetpack
Apache License 2.0
17.65k stars 4.71k forks source link

Modify collectAsState to collectAsStateWithLifecycle #976

Closed pachuho closed 3 months ago

pachuho commented 3 months ago

Use collectAsStateWithLifecycle to save app resources when you don't need them, such as when they're in the background.

The following tasks have been applied.

  1. add dependency androidx.lifecycle.lifecycle-runtime-compose
  2. modify flow to stateFlow in viewModel
  3. modify collectAsState to collectAsStateWithLifecycle in Composable Screen
google-cla[bot] commented 3 months ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.