I call this function when app startup and stuck on...
# coroutines
j
I call this function when app startup and stuck on loading screen . Here is the log console when debug:
Copy code
Log: Before delay
Log: Init Status: true
Log: Job Status: true
getUserInfo()
will not be called at all ??? What’s happen with flow ?
Copy code
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)
            }
}
y
It's waiting init to be done
j
No, even init is done. It still keep waiting status. I think should be make a
job
when waiting initFinish. If it to be done, cancel this job.
y
Does initFinish flow ever finish?