Examples include using the Room component, reading from or writing to files, and running any network operations. Dispatchers.IO - This dispatcher is optimized to perform disk or network I/O outside of the main thread.Examples include calling suspend functions, running Android UI framework operations, and updating LiveData objects. This should be used only for interacting with the UI and performing quick work. Dispatchers.Main - Use this dispatcher to run a coroutine on the main Android thread.To specify where the coroutines should run, Kotlin provides three dispatchers that you can use: To understand suspend functions, we should also know about provided dispatchers by Kotlin. Suspend and resume work together to replace callbacks. We use call back functions when we get response from our Async task. You can only call suspend functions from other suspend functions, or by using a coroutine builder like launch to start a new coroutine.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |