@@ -45,7 +45,7 @@ import kotlin.coroutines.intrinsics.*
45
45
* * Note how coroutine builders are scoped: if activity is destroyed or any of the launched coroutines
46
46
* * in this method throws an exception, then all nested coroutines are cancelled.
47
47
* */
48
- * fun loadDataFromUI () = launch { // <- extension on current activity, launched in the main thread
48
+ * fun showSomeData () = launch { // <- extension on current activity, launched in the main thread
49
49
* val ioData = async(Dispatchers.IO) { // <- extension on launch scope, launched in IO dispatcher
50
50
* // blocking I/O operation
51
51
* }
@@ -177,13 +177,13 @@ object GlobalScope : CoroutineScope {
177
177
* Example of the scope usages looks like this:
178
178
*
179
179
* ```
180
- * suspend fun loadDataForUI () = coroutineScope {
180
+ * suspend fun showSomeData () = coroutineScope {
181
181
*
182
182
* val data = async { // <- extension on current scope
183
183
* ... load some UI data ...
184
184
* }
185
185
*
186
- * withContext(UI ) {
186
+ * withContext(Dispatchers.Main ) {
187
187
* doSomeWork()
188
188
* val result = data.await()
189
189
* display(result)
@@ -192,9 +192,9 @@ object GlobalScope : CoroutineScope {
192
192
* ```
193
193
*
194
194
* Semantics of the scope in this example:
195
- * 1) `loadDataForUI ` returns as soon as data is loaded and UI is updated .
196
- * 2) If `doSomeWork` throws an exception, then `async` task is cancelled and `loadDataForUI ` rethrows that exception.
197
- * 3) If outer scope of `loadDataForUI ` is cancelled, both started `async` and `withContext` are cancelled.
195
+ * 1) `showSomeData ` returns as soon as data is loaded and displayed in UI .
196
+ * 2) If `doSomeWork` throws an exception, then `async` task is cancelled and `showSomeData ` rethrows that exception.
197
+ * 3) If outer scope of `showSomeData ` is cancelled, both started `async` and `withContext` are cancelled.
198
198
*
199
199
* Method may throw [CancellationException] if the current job was cancelled externally
200
200
* or may throw the corresponding unhandled [Throwable] if there is any unhandled exception in this scope
@@ -226,7 +226,6 @@ public fun CoroutineScope(context: CoroutineContext): CoroutineScope =
226
226
* Example of use:
227
227
* ```
228
228
* class MyAndroidActivity: CoroutineScope by MainScope(CoroutineName("MyActivity"))) {
229
- *
230
229
* override fun onDestroy() {
231
230
* super.onDestroy()
232
231
* cancel() // CoroutineScope.cancel
0 commit comments