why launch by itself doesnt exist for example when...
# announcements
c
why launch by itself doesnt exist for example when you say launch{} it says
unresolved reference
d
If you just
launch
"by itself" then you have a resource leak: You now have a coroutine running but nobody will take care to shut it down. You always need a
CoroutineScope
to ensure that resources are properly cleaned up. Some resources: https://kotlinlang.org/docs/reference/coroutines/basics.html#structured-concurrency https://medium.com/@elizarov/structured-concurrency-722d765aa952 https://medium.com/@elizarov/structured-concurrency-anniversary-f2cc748b2401
You can launch things globally, but you have to be explicit about it:
GlobalScope.launch
.