Kotlinx.coroutines: CoroutineScope "context" shadows Android context

Created on 20 Jun 2017  路  3Comments  路  Source: Kotlin/kotlinx.coroutines

In Android Activities, Fragments, and Views there is a getContext() method that is used frequently. When used with Kotlin the IDE suggests using property access syntax with the synthetic property context. This is shadowed when using an async or launch coroutine block, though, by the CoroutineContext context of CoroutineScope.

We can use getContext() instead and it's not the end of the world, but I wanted to file the issue to see if there should instead be an alternate name for the CoroutineContext. I imagine many people will run into this "issue" whether writing code or reading other's code and getting confused by the two different "contexts".

Cheers.

Most helpful comment

The tentative plan is to rename it coroutineContext. Stay tuned.

All 3 comments

The tentative plan is to rename it coroutineContext. Stay tuned.

Committed rename of context to coroutineContext into develop branch.

Released in version 0.17

Was this page helpful?
0 / 5 - 0 ratings

Related issues

elizarov picture elizarov  路  3Comments

sky87 picture sky87  路  3Comments

elizarov picture elizarov  路  3Comments

ScottPierce picture ScottPierce  路  3Comments

mgj picture mgj  路  3Comments