android10 / android10/Android-CleanArchitecture-Kotlin
Asynchronous approach for UseCase execute function
- Lingua principale
- Kotlin
- Stelle
- 4.8k
- Fork
- 929
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Hi,
Currently I found that You do it this way
```
val job = async(CommonPool) { run(params) }
launch(UI) { onResult.invoke(job.await()) }
```
Can we just create one coroutine here and just do context switching to execute the UI block code, maybe something like this
```
launch(CommonPool + job) {
val result = async(coroutineContext) { run(params) }
withContext(UI) { onResult.invoke(result.await()) }
}
```
And the ```job``` on this sample is a private property for cancellation purpose.
By the way, thank you so much for always providing us with such an awesome resources. 👍 🙇
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.