Skip to content

Commit 849a848

Browse files
committed
Polishing
1 parent 66c95dc commit 849a848

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/docs/asciidoc/languages/kotlin.adoc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,9 @@ for more details and up-to-date information.
295295

296296
Spring Framework comes with a Kotlin router DSL available in 3 flavors:
297297

298-
* WebMvc.fn {doc-root}/spring-framework/docs/{spring-version}/kdoc-api/spring-framework/org.springframework.web.servlet.function/router.html[router { }]
299-
* WebFlux.fn <<web-reactive#webflux-fn, Reactive>> {doc-root}/spring-framework/docs/{spring-version}/kdoc-api/spring-framework/org.springframework.web.reactive.function.server/router.html[router { }]
300-
* WebFlux.fn <<Coroutines>> {doc-root}/spring-framework/docs/{spring-version}/kdoc-api/spring-framework/org.springframework.web.reactive.function.server/co-router.html[coRouter { }]
298+
* WebMvc.fn DSL with {doc-root}/spring-framework/docs/{spring-version}/kdoc-api/spring-framework/org.springframework.web.servlet.function/router.html[router { }]
299+
* WebFlux.fn <<web-reactive#webflux-fn, Reactive>> DSL with {doc-root}/spring-framework/docs/{spring-version}/kdoc-api/spring-framework/org.springframework.web.reactive.function.server/router.html[router { }]
300+
* WebFlux.fn <<Coroutines>> DSL with {doc-root}/spring-framework/docs/{spring-version}/kdoc-api/spring-framework/org.springframework.web.reactive.function.server/co-router.html[coRouter { }]
301301

302302
These DSL let you write clean and idiomatic Kotlin code to build a `RouterFunction` instance as the following example shows:
303303

@@ -426,16 +426,17 @@ For return values, the translation from Reactive to Coroutines APIs is the follo
426426
For input parameters:
427427

428428
* If laziness is not needed, `fun handler(mono: Mono<T>)` becomes `fun handler(value: T)` since a suspending functions can be invoked to get the value parameter.
429-
* If laziness is needed, `fun handler(mono: Mono<T>)` becomes `fun handler(supplier: () -> T)` or `fun handler(supplier: () -> T?)`
429+
* If laziness is needed, `fun handler(mono: Mono<T>)` becomes `fun handler(supplier: suspend () -> T)` or `fun handler(supplier: suspend () -> T?)`
430430

431431
https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html[`Flow`] is `Flux` equivalent in Coroutines world, suitable for hot or cold stream, finite or infinite streams, with the following main differences:
432432

433433
* `Flow` is push-based while `Flux` is push-pull hybrid
434434
* Backpressure is implemented via suspending functions
435435
* `Flow` has only a https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/collect.html[single suspending `collect` method] and operators are implemented as https://kotlinlang.org/docs/reference/extensions.html[extensions]
436-
* https://github.com/Kotlin/kotlinx.coroutines/tree/master/kotlinx-coroutines-core/common/src/flow/operators[Operators are easy to implement] thanks to Coroutines and extensions allow to add custom ones easily to `Flow`
436+
* https://github.com/Kotlin/kotlinx.coroutines/tree/master/kotlinx-coroutines-core/common/src/flow/operators[Operators are easy to implement] thanks to Coroutines
437+
* Extensions allow to add custom operators to `Flow`
437438
* Collect operations are suspending functions
438-
* `map` operator supports asynchronous operation (no need for `flatMap`) since it takes a suspending function parameter
439+
* https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/map.html[`map` operator] supports asynchronous operation (no need for `flatMap`) since it takes a suspending function parameter
439440

440441
Read this blog post about https://medium.com/@elizarov/structured-concurrency-722d765aa952[structured concurrency]
441442
to understand how to run code concurrently with Coroutines and how are managed exceptions and cancellations.
@@ -508,12 +509,12 @@ class CoroutinesRestController(client: WebClient, banner: Banner) {
508509
}
509510
510511
@GetMapping("/error")
511-
suspend fun error(): ServerResponse {
512+
suspend fun error() {
512513
throw IllegalStateException()
513514
}
514515
515516
@GetMapping("/cancel")
516-
suspend fun cancel(): ServerResponse {
517+
suspend fun cancel() {
517518
throw CancellationException()
518519
}
519520

0 commit comments

Comments
 (0)