@@ -346,7 +346,12 @@ CompletableFuture is considered a non-blocking type which is able to produces a
346346
347347==== RxJava
348348
349- Jooby produces different responses based on the reactive type: `Single` vs `Flowable`
349+ 1) Add the https://github.com/ReactiveX/RxJava[RxJava] dependency:
350+
351+ [dependency, artifactId="rxjava"]
352+ .
353+
354+ 2) Write code:
350355
351356===== Single
352357
@@ -374,8 +379,6 @@ Jooby produces different responses based on the reactive type: `Single` vs `Flow
374379}
375380----
376381
377- Jooby is able to set the `Content-Length` header when using *Single* responses.
378-
379382===== Flowable
380383
381384.Java
@@ -400,17 +403,74 @@ Jooby is able to set the `Content-Length` header when using *Single* responses.
400403}
401404----
402405
403- Flowable responses are handled bit different because is impossible to know how many item are going
404- to be generated.
405-
406- Jooby builds a `chunked` response. That:
406+ For Flowable, Jooby builds a `chunked` response. That:
407407
408408. Set the `Transfer-Encoding: chunked` header
409409. Each item means new `chunk` send it to client
410410
411411==== Reactor
412412
413- It works like <<RxJava>> using reactor types `Mono` and `Flux`.
413+ 1) Add the https://projectreactor.io/[Reactor] dependency:
414+
415+ [dependency, artifactId="reactor-core"]
416+ .
417+
418+ 2) Write code:
419+
420+ ===== Mono
421+
422+ .Java
423+ [source,java, role="primary"]
424+ ----
425+ {
426+ get("/non-blocking", ctx -> {
427+ return Mono
428+ .fromCallable(() -> "Mono")
429+ .map(it -> "Hello " + it);
430+ })
431+ }
432+ ----
433+
434+ .Kotlin
435+ [source,kotlin,role="secondary"]
436+ ----
437+ {
438+ get("/non-blocking") {
439+ Mono
440+ .fromCallable { "Mono" }
441+ .map { "Hello $it" }
442+ }
443+ }
444+ ----
445+
446+ ===== Flux
447+
448+ .Java
449+ [source,java, role="primary"]
450+ ----
451+ {
452+ get("/non-blocking", ctx -> {
453+ return Flux.range(1, 10)
454+ .map(it -> it + ", ");
455+ })
456+ }
457+ ----
458+
459+ .Kotlin
460+ [source,kotlin,role="secondary"]
461+ ----
462+ {
463+ get("/non-blocking") {
464+ Flux.range(1, 10)
465+ .map{ "$it, " }
466+ }
467+ }
468+ ----
469+
470+ For Flux, Jooby builds a `chunked` response. That:
471+
472+ . Set the `Transfer-Encoding: chunked` header
473+ . Each item means new `chunk` send it to client
414474
415475==== Kotlin Coroutines
416476
0 commit comments