Jason
01/22/2021, 7:16 AMLog: Before delay
Log: Init Status: true
Log: Job Status: true
getUserInfo()
will not be called at all ??? What’s happen with flow ?
interface InitRepository {
val initFinish: Flow<Boolean>
}
suspend fun startApp() {
checkStatus()
waitInitializeDone() -> App is stuck on waiting here... Forever waiting
getUserInfo()
}
suspend fun waitInitializeDone() {
withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
val waitJob = launch {
Log.d("Before delay")
delay(10000L)
throw TimeoutException("Init process timeout")
}
initRepository.initFinish
.onEach { initFinish ->
Log.d("Init Status: $initFinish")
Log.d("Job Status: ${waitJob.isActive}")
if (initFinish && waitJob.isActive) {
waitJob.cancel()
}
}
.launchIn(this)
}
}
Yigitunlu
01/25/2021, 3:44 PMJason
01/26/2021, 8:34 AMjob
when waiting initFinish. If it to be done, cancel this job.Yigitunlu
01/26/2021, 9:05 AM