Search⌘ K

Challenge: Practice a Suspending Function Using Flow

Explore how to implement a suspending function using Kotlin Flow within a coroutine. This lesson helps you practice managing asynchronous data streams, delays, and user output, reinforcing your understanding of Flow and coroutine behavior.

We'll cover the following...

Problem

Write a program where you will try to complete the code by starting a coroutine. The coroutine will keep processing three times with a delay of 0.1 seconds, and when the coroutines end, it will print the name of users with a delay of 1 second. You have to make a suspending function named getFlow using Flow, and this function will print the user’s count.

Restriction

The output will be available in the terminal.

Output ...