Let's say I have the following coroutine:
lifecycleScope.launch(Dispatchers.IO) {
}
If I want to switch Dispatchers
within the above coroutine, I can do it in the following two ways: withContext(Dispatchers.Main) {}
or launch(Dispatchers.Main) {}
.
What's the difference between the two ways of switching Dispatchers
? Are they basically doing the same thing, but with a different syntax?