Skip to content

Commit 1ccc968

Browse files
Move async-style warning above the paragraph in question (#3835)
1 parent b78bbf5 commit 1ccc968

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/topics/composing-suspending-functions.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ standard `lazy` function in cases when computation of the value involves suspend
189189

190190
## Async-style functions
191191

192+
> This programming style with async functions is provided here only for illustration, because it is a popular style
193+
> in other programming languages. Using this style with Kotlin coroutines is **strongly discouraged** for the
194+
> reasons explained below.
195+
>
196+
{type="note"}
197+
192198
We can define async-style functions that invoke `doSomethingUsefulOne` and `doSomethingUsefulTwo`
193199
_asynchronously_ using the [async] coroutine builder using a [GlobalScope] reference to
194200
opt-out of the structured concurrency.
@@ -275,12 +281,6 @@ The answer is 42
275281
Completed in 1085 ms
276282
-->
277283

278-
> This programming style with async functions is provided here only for illustration, because it is a popular style
279-
> in other programming languages. Using this style with Kotlin coroutines is **strongly discouraged** for the
280-
> reasons explained below.
281-
>
282-
{type="note"}
283-
284284
Consider what happens if between the `val one = somethingUsefulOneAsync()` line and `one.await()` expression there is some logic
285285
error in the code, and the program throws an exception, and the operation that was being performed by the program aborts.
286286
Normally, a global error-handler could catch this exception, log and report the error for developers, but the program

0 commit comments

Comments
 (0)