Skip to content

Commit

Permalink
added lifecycle state
Browse files Browse the repository at this point in the history
  • Loading branch information
anandwana001 committed Dec 2, 2024
1 parent 0840672 commit 3fa12e8
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.ComposeView
import androidx.core.view.WindowInsetsCompat
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.navigation.NavController
import androidx.navigation.NavDirections
import androidx.navigation.fragment.NavHostFragment
Expand Down Expand Up @@ -81,7 +83,11 @@ class MainActivity : AbstractActivity() {
}
}

lifecycleScope.launch { navigator.getNavigateRequests().collect { onNavigate(it) } }
lifecycleScope.launch {
lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) {
navigator.getNavigateRequests().collect { onNavigate(it) }
}
}

val binding = MainActBinding.inflate(layoutInflater)
setContentView(binding.root)
Expand Down

0 comments on commit 3fa12e8

Please sign in to comment.