Kotlin coroutines provide a concise & elegant syntax for running concurrent & async tasks. Unlike callbacks, suspend funs can be wrapped & chained.
…but my legacy component only provides a callback interface
TimePicker dialogs are such a case! We just want a value from the user, but we cannot return that value directly, since the picker is launched asynchronously. So we’re stuck with ugly callbacks:
Fortunately, Kotlin coroutines provide an extension precisely for this scenario: