From the course: Kotlin Essential Training: Object-Oriented and Async Code
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Challenge: Manage multiple async requests - Kotlin Tutorial
From the course: Kotlin Essential Training: Object-Oriented and Async Code
Challenge: Manage multiple async requests
(upbeat music) - [Instructor] Let's get some hands-on practice with coroutines. In this challenge, your task is to use coroutines to parallelize the execution of two suspending functions. We have load items from DB and load items from network. These functions simulate making blocking requests to a database into the network. Your task is to use the async coroutine builder to run both functions at the same time and then to use deferred data wait, to get the results of both async calls. Convert those results into a unified list and print out that unified list to the console. The resulting code should run in approximately five seconds if the coroutines are running in parallel.