marcinmoskala
11/11/2025, 10:49 AMmarcinmoskala
11/11/2025, 10:50 AMSam
11/11/2025, 10:58 AMonCreate() method of an Android activity.
e.g.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
scope.launch(Dispatchers.Main) {
// queued for dispatch; runs second
println("Second")
}
scope.launch(Dispatchers.Main.immediate) {
// runs first (inline), no dispatch
// (because onCreate was already running on the main thread)
println("First")
}
}
Android's not my area of expertise though, so maybe I misunderstood what you're asking about or I got some details wrong. Does this help demonstrate the difference you were looking for?Sam
11/11/2025, 11:11 AMwithContext always makes the same guarantee about not redispatching when the dispatcher hasn't changed, regardless of which dispatcher you're using, though I can't find that exact wording in the documentation right now 🤔CLOVIS
11/11/2025, 11:30 AMmarcinmoskala
11/12/2025, 6:20 PM