Kotlin coroutines integration#
mutiny-kotlin provides an integration with Kotlin coroutines.
There are currently four extension methods available for converting between Mutiny and Kotlin coroutine types offered in a separate package. For implementation details please have also a look to these methods documentation.
The extension functions are shipped in the package
You need to add the following dependency to your project:
Awaiting a Uni in coroutines#
Within a coroutine or suspend function you can easily await Uni events in a suspended way:
Processing a Multi as Flow#
Flow type matches
Multi semantically, even though it isn’t a feature complete reactive streams implementation.
You can process a
Flow as follows:
Providing a Deferred value as Uni#
The other way around is also possible, let a Deferred become a Uni:
Creating a Multi from a Flow#
Finally, creating a Multi from a Flow is also possible: