Skip to content

JS transform suspend with Result return type to Promise #99

@Yentis

Description

@Yentis

I was wondering if it would be possible to have a transformer that converts
suspend fun foo(): Result<String>
to
fun foo(): Promise<String>
instead of
fun foo(): Promise<Result<String>>

I was thinking something like

fun <T> toAsync(block: suspend () -> Result<T>): Promise<T> {
    return coroutineScope.promise { block().getOrThrow() }
}

which technically works as a custom transformer but the return type isn't correct

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions