evan
01/18/2019, 8:54 PMGlobalScope.launch
, awaits a deferred value, prints its contents, and then outside of the launch method, prints a concluding String. All of this is working great. The process is still running when these two print tasks complete however. What is keeping it alive, and can I gracefully shutdown when all my work has been completed?
Edit: Updated code block from Louis' comments
suspend fun main() {
val api = createRestApi<RestApi>("<https://catfact.ninja/>", okHttpClient(), moshi)
coroutineScope {
val facts = api.getFacts().await()
println(facts.data)
}
println("That's all")
}
louiscad
01/18/2019, 9:14 PMcoroutineScope { … }
instead of using GlobalScope
launch
and join
evan
01/18/2019, 9:17 PMstreetsofboston
01/18/2019, 11:36 PM