Junior — Senior
Determining which dispatcher is running Flow operations
livecode
Task condition
The example uses a flow intFlow, to which map, filter, and single operations are sequentially applied. Between these operations, flowOn is called with different dispatchers (Dispatchers.IO and Dispatchers.Default). It is necessary to specify in which dispatcher each of the map, filter, and single operations will be executed.
withContext(Dispatchers.Main) {
val singleValue = intFlow
.map { /* where will the code be executed? */ }
.flowOn(Dispatchers.IO)
.filter { /* where will the code be executed? */ }
.flowOn(Dispatchers.Default)
.single() // and here?
}