Day160 — Return a value from a kotlin coroutine scope

Return value within a coroutine scope

Return value outside a coroutine scope

Use invokeOnCompletion when it is really necessary because it has no difference from “Return value within a coroutine scope” with a CoroutineExceptionHandler to me. And it disrupts the coroutine pattern by introducing a callback.

They do the same thing. I prefer the first one, handling everything within a coroutine scope.

These two are the same.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store