An asynchronous function with a flexible dispatcher
We can bring back some flexibility to this function by making the dispatcher an optional parameter of the function:
private val defDsp = newSingleThreadContext(name = "ServiceCall") private fun asyncLoadNews(dispatcher: CoroutineDispatcher = defDsp) = launch(dispatcher) { ... }
This approach has more flexibility, since now the caller can use a specific CoroutineDispatcher to run this code, but it still has the downside of being explicit only if an appropriate name is given to the function.