Skip to content

Commit

Permalink
Make DB flow collection lifecycle aware
Browse files Browse the repository at this point in the history
  • Loading branch information
hichamboushaba committed Dec 10, 2024
1 parent a25dfe5 commit 9375f2d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ androidx-hilt-navigation-fragment = { group = "androidx.hilt", name = "hilt-navi
androidx-hilt-work = { group = "androidx.hilt", name = "hilt-work", version.ref = "androidx-hilt" }
androidx-lifecycle-livedata-ktx = { group = "androidx.lifecycle", name = "lifecycle-livedata-ktx", version.ref = "androidx-lifecycle" }
androidx-lifecycle-process = { group = "androidx.lifecycle", name = "lifecycle-process", version.ref = "androidx-lifecycle" }
androidx-lifecycle-runtime-compose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "androidx-lifecycle" }
androidx-lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "androidx-lifecycle" }
androidx-lifecycle-viewmodel-savedstate = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-savedstate", version.ref = "androidx-lifecycle" }
androidx-navigation-common = { group = "androidx.navigation", name = "navigation-common", version.ref = "androidx-navigation" }
Expand Down
1 change: 1 addition & 0 deletions libs/apifaker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ android {
dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.lifecycle.runtime.compose)

implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.material.main)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.woocommerce.android.apifaker.models.ApiType
Expand All @@ -46,7 +47,7 @@ internal fun HomeScreen(
onExit: () -> Unit
) {
HomeScreen(
endpoints = viewModel.endpoints.collectAsState().value,
endpoints = viewModel.endpoints.collectAsStateWithLifecycle().value,
isEnabled = viewModel.isEnabled.collectAsState(initial = false).value,
navController = navController,
onMockingToggleChanged = viewModel::onMockingToggleChanged,
Expand Down

0 comments on commit 9375f2d

Please sign in to comment.