Skip to content

Commit 6d7a216

Browse files
elizarovqwwdfsad
authored andcommitted
Wording in docs is improved
1 parent 8e9e4d1 commit 6d7a216

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

common/kotlinx-coroutines-core-common/src/CoroutineScope.kt

+8-8
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public operator fun CoroutineScope.plus(context: CoroutineContext): CoroutineSco
7474
ContextScope(coroutineContext + context)
7575

7676
/**
77-
* Creates [CoroutineScope] for a UI components.
77+
* Creates the main [CoroutineScope] for UI components.
7878
*
7979
* Example of use:
8080
* ```
@@ -89,9 +89,9 @@ public operator fun CoroutineScope.plus(context: CoroutineContext): CoroutineSco
8989
*
9090
* ```
9191
*
92-
* Resulting scope has [SupervisorJob] and [Dispatchers.Main].
93-
* If you want to append additional elements to main scope, use [CoroutineScope.plus] operator:
94-
* `val scope = MainScope() + CoroutineName("MyActivity") `.
92+
* The resulting scope has [SupervisorJob] and [Dispatchers.Main] context elements.
93+
* If you want to append additional elements to the main scope, use [CoroutineScope.plus] operator:
94+
* `val scope = MainScope() + CoroutineName("MyActivity")`.
9595
*/
9696
@Suppress("FunctionName")
9797
public fun MainScope(): CoroutineScope = ContextScope(SupervisorJob() + Dispatchers.Main)
@@ -198,13 +198,13 @@ public fun CoroutineScope(context: CoroutineContext): CoroutineScope =
198198

199199
/**
200200
* Cancels this scope, including its job and all its children.
201-
* Throws [IllegalStateException] if scope does not have a job in it.
201+
* Throws [IllegalStateException] if the scope does not have a job in it.
202202
*
203-
* This API is experimental in order to investigate possible clashes with other cancellation mechanism.
203+
* This API is experimental in order to investigate possible clashes with other cancellation mechanisms.
204204
*/
205205
@Suppress("NOTHING_TO_INLINE")
206-
@ExperimentalCoroutinesApi // Experimental and inline until 1.2
206+
@ExperimentalCoroutinesApi // Experimental and inline since 1.1.0, tentatively until 1.2.0
207207
public inline fun CoroutineScope.cancel() {
208-
val job = coroutineContext[Job] ?: error("Current scope cannot be cancelled because it does not have a job: $this")
208+
val job = coroutineContext[Job] ?: error("Scope cannot be cancelled because it does not have a job: $this")
209209
job.cancel()
210210
}

ui/coroutines-guide-ui.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ collection of the whole trees of UI objects that were already destroyed and will
470470

471471
The natural solution to this problem is to associate a [Job] object with each UI object that has a lifecycle and create
472472
all the coroutines in the context of this job. But passing associated job object to every coroutine builder is error-prone,
473-
it is easy to forget it. For this purpose, [CoroutineScope] interface should be implemented by UI owner, and then every
473+
it is easy to forget it. For this purpose, [CoroutineScope] interface could be implemented by UI owner, and then every
474474
coroutine builder defined as an extension on [CoroutineScope] inherits UI job without explicitly mentioning it.
475475
For the sake of simplicity, [MainScope()] factory can be used. It automatically provides `Dispatchers.Main` and parent
476476
job.

0 commit comments

Comments
 (0)