Skip to content

Commit

Permalink
Ensure app start task is launched in parallel with other SplashViewMo…
Browse files Browse the repository at this point in the history
…del tasks
  • Loading branch information
ksharma-xyz committed Feb 28, 2025
1 parent 81ad0a9 commit 2dbaeb0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package xyz.ksharma.krail.splash
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
Expand Down Expand Up @@ -33,9 +34,13 @@ class SplashViewModel(
private val _isLoading: MutableStateFlow<Boolean> = MutableStateFlow(false)
val isLoading: StateFlow<Boolean> = _isLoading
.onStart {
loadKrailThemeStyle()
trackAppStartEvent()
appStart.start()
coroutineScope {
appStart.start()
}
coroutineScope {
loadKrailThemeStyle()
trackAppStartEvent()
}
}.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), true)

private suspend fun trackAppStartEvent() = with(appInfoProvider.getAppInfo()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package xyz.ksharma.krail.core.appstart

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import xyz.ksharma.krail.core.log.log
import xyz.ksharma.krail.core.remote_config.RemoteConfig
Expand Down

0 comments on commit 2dbaeb0

Please sign in to comment.