Chad Gregory
08/04/2022, 4:19 PMdefaultRequest
block. has anyone else did this? How did you go about it?Aleksei Tirman [JB]
08/05/2022, 8:32 AMdefaultRequest
block.Chad Gregory
08/05/2022, 11:53 AMsingle()
over collect{}
but that didn't work either.
What I ended up doing was in my runBlocking I just added a small delay delay(250L)
and that was enough time for the url to be received from my datastore. I still want a better solution than that, my guess is I need to modify my return of flow to something else instead that actually finish which then the solution you gave would work.Chad Gregory
08/05/2022, 11:56 AMAleksei Tirman [JB]
08/05/2022, 11:56 AMChad Gregory
08/05/2022, 12:32 PMChad Gregory
08/05/2022, 12:51 PMrunBlocking{}
and Flow<T>.first()
to block while the value is retrieve. The reason I did not replace my val with the function is there are places where I need the information as well where I can utilize coroutines properly where I am not initializing components on my app
val getTerminalDetails: Flow<TerminalDetails> = cxt.terminalDetails.data
.catch { e ->
if (e is IOException) {
Log.d("Error", e.message.toString())
emit(TerminalDetails.getDefaultInstance())
} else {
throw e
}
}
fun getTerminalDetails(): TerminalDetails = runBlocking {
cxt.terminalDetails.data.first()
}