Skip to content

Asynchronous approach for UseCase execute function #31

@khairilushan

Description

@khairilushan

Hi,
Currently I found that You do it this way

val job = async(CommonPool) { run(params) }
launch(UI) { onResult.invoke(job.await()) }

Can we just create one coroutine here and just do context switching to execute the UI block code, maybe something like this

launch(CommonPool + job) {
    val result = async(coroutineContext) { run(params) }
    withContext(UI) { onResult.invoke(result.await()) }
}

And the job on this sample is a private property for cancellation purpose.

By the way, thank you so much for always providing us with such an awesome resources. 👍 🙇

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions