Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seemingly unnecessary suspend modifier on uni coroutine builder #1324

Closed
FWest98 opened this issue Jul 25, 2023 · 1 comment · Fixed by #1323
Closed

Seemingly unnecessary suspend modifier on uni coroutine builder #1324

FWest98 opened this issue Jul 25, 2023 · 1 comment · Fixed by #1323
Assignees

Comments

@FWest98
Copy link

FWest98 commented Jul 25, 2023

Currently, the uni coroutine builder has a suspend modifier. However, this seems to be unnecessary: async itself is not a suspending function and simply returns a Deferred. Removing the suspend modifier then allows us to actually use the uni builder as intended: to call a suspending function (inside the async block) and have it be transformed to a mutiny Uni target. With the suspend modifier present, we would need to use a suspending function to be able to return the Uni - defeating the purpose of this "bridge" between mutiny and coroutines.

@ExperimentalCoroutinesApi
@OptIn(DelicateCoroutinesApi::class)
suspend fun <T> uni(context: CoroutineScope = GlobalScope, suspendSupplier: suspend () -> T): Uni<T> = context.async {
suspendSupplier()
}.asUni()

Please correct me if I'm missing a detail here, but my naive tests recreating the uni function without the keyword seem to work perfectly fine. The issue seems similar to #1316 and #1323

@heubeck
Copy link
Collaborator

heubeck commented Jul 25, 2023

Thank you for reporting. Fixed with #1323

@heubeck heubeck self-assigned this Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants