![]() WithContext also happens to be optimized, leveraging the fact that you're suspending the parent coroutine and awaiting on the child, but that's just an added bonus.Īsync-await should be reserved for those cases where you actually want concurrency, so that you launch several coroutines in the background and only then await on them. Update: Kotlin 1.2.50 now has a code inspection where it can convert async(ctx) simply gets thrown by the withContext call, you handle it just like any other. Is there a case async-await is more preferable to withContext? Large numbers of coroutines, although lightweight, could still be a problem in demanding applications. Isn't it always better to use withContext rather than async-await as it is functionally similar, but doesn't create another coroutine.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |