Skip to content

Add context parameter based CoroutineScope APIs #4534

@Stream29

Description

@Stream29

Use case

Current coroutine scope APIs like CoroutineScope.launch are receiver-based.
It's pervasive, just like function coloring.

According to it's semantic, a CoroutineScope is more fit as a context element if we have context parameter.
In Kotlin, a function can have at most two receiver for now, and this new API will make the receiver more free.

The Shape of the API

Example:

context(scope: CoroutineScope)
public fun launch(context(CoroutineScope) suspend () -> Unit): Job {
    // ...
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions