CLOVIS
09/11/2024, 7:00 AMsuspend fun getFriends(): List<User> {
report(loading(0.0)) // 0%
val currentUser = findMe()
report(loading(0.5)) // 50%
val friends = findFriendsOf(currentUser)
report(done())
return friends
}
val logger = ProgressReporter { println("Get friends: $it") }
withContext(logger.asCoroutineContext()) {
getFriends()
}
// Output:
Get friends: Loading(0%)
Get friends: Loading(50%)
Get friends: Done
Progress is ideal when developing Compose applications to improve UX of long operations. It can also be used without coroutines, if needed.
Learn more: documentation • what's new? • #C078Z1QRHL3