eucalypto / learn

These are projects that help me learn
0 stars 0 forks source link

Sandbox #30

Open eucalypto opened 3 years ago

eucalypto commented 3 years ago

This project is to simply try out different small stuff to see how it works - like a sandbox.

eucalypto commented 3 years ago

Kotlin Coroutines must be started in a scope. This is handy because once the scope is cancelled, all the child coroutines are cancelled as well.

AndroidX offers pre-defined coroutine contexts:

See this nice article: https://vladsonkin.com/android-coroutine-scopes-how-to-handle-a-coroutine/

The question is: On what threads do those coroutines run?

eucalypto commented 3 years ago

Answer:

GlobalScope : DefaultDispatcher (background thread?) LifecycleScope : main thread (UI) ViewModelScope : main thread (UI)