Skip to content

Commit 516792d

Browse files
committed
update reactive doc to reflect the new global mapper
1 parent 6390f0b commit 516792d

File tree

2 files changed

+12
-104
lines changed

2 files changed

+12
-104
lines changed

md/doc/reactor/reactor.md

Lines changed: 7 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ import org.jooby.reactor.Reactor;
2626
{
2727
use(new Reactor());
2828

29-
get("/", () -> Flux.just("reactive programming in jooby!"))
30-
.map(Reactor.reactor());
29+
/** Deal with Flux & Mono. */
30+
mapper(Reactor.reactor());
31+
32+
get("/", () -> Flux.just("reactive programming in jooby!"));
3133
}
3234
```
3335

@@ -51,53 +53,6 @@ Previous example is translated to:
5153

5254
Translation is done with the [Reactor.reactor()]({{defdocs}}/reactor/Reactor.html#reactor--) route operator. If you are a <a href="http://projectreactor.io">reactor</a> programmer then you don't need to worry for learning a new API and semantic. The [Reactor.reactor()]({{defdocs}}/reactor/Reactor.html#reactor--) route operator deal and take cares of the [Deferred API]({{defdocs}}/Deferred.html).
5355

54-
## reactor()
55-
56-
We just learn that we are not force to learn a new API, just write <a href="http://projectreactor.io">reactor</a> code. That's cool!
57-
58-
But.. what if you have 10 routes? 50 routes?
59-
60-
```java
61-
...
62-
import org.jooby.reactor.Reactor;
63-
...
64-
{
65-
use(new Reactor());
66-
67-
get("/1", req -> Observable...)
68-
.map(Reactor.reactor());
69-
70-
get("/2", req -> Observable...)
71-
.map(Reactor.reactor());
72-
....
73-
74-
get("/N", req -> Observable...)
75-
.map(Reactor.reactor());
76-
}
77-
```
78-
79-
This is better than written N routes using the [Deferred API]({{defdocs}}/Deferred.html)... but still there is one more option to help you (and your fingers) to right less code:
80-
81-
```java
82-
...
83-
import org.jooby.reactor.Reactor;
84-
...
85-
{
86-
use(new Reactor());
87-
88-
with(() -> {
89-
get("/1", () -> Observable...);
90-
get("/2", () -> Observable...);
91-
....
92-
get("/N", () -> Observable...);
93-
}).map(Reactor.reactor());
94-
95-
}
96-
```
97-
98-
**Beautiful, hugh?**
99-
100-
The [with]({{defdocs}}/Routes.html#with-java.lang.Runnable-) operator let you group any number of routes and apply common attributes and/or operator to all them!!!
10156

10257
## reactor()+scheduler
10358

@@ -112,10 +67,10 @@ import org.jooby.reactor.Reactor;
11267

11368
with(() -> {
11469

115-
get("/1", () -> Observable...);
116-
get("/2", () -> Observable...);
70+
get("/1", () -> Flux...);
71+
get("/2", () -> Flux...);
11772
....
118-
get("/N", () -> Observable...);
73+
get("/N", () -> Flux...);
11974
}).map(Reactor.reactor(Computations::concurrent));
12075

12176
}

md/doc/rxjava/rxjava.md

Lines changed: 5 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ import org.jooby.rx.Rx;
2929
{
3030
use(new Rx());
3131

32-
get("/", () -> Observable.from("reactive programming in jooby!"))
33-
.map(Rx.rx());
32+
/** Deal with Observable, Single and others .*/
33+
mapper(Rx.rx());
34+
35+
get("/", () -> Observable.from("reactive programming in jooby!"));
36+
3437
}
3538
```
3639

@@ -54,56 +57,6 @@ Previous example is translated to:
5457

5558
Translation is done with the [Rx.rx()]({{defdocs}}/rx/Rx.html#rx--) route operator. If you are a <a href="https://github.com/ReactiveX/RxJava">RxJava</a> programmer then you don't need to worry for learning a new API and semantic. The [Rx.rx()]({{defdocs}}/rx/Rx.html#rx--) route operator deal and take cares of the [Deferred API]({{defdocs}}/Deferred.html).
5659

57-
## rx()
58-
59-
We just learn that we are not force to learn a new API, just write <a href="https://github.com/ReactiveX/RxJava">RxJava</a> code. That's cool!
60-
61-
But.. what if you have 10 routes? 50 routes?
62-
63-
```java
64-
...
65-
import org.jooby.rx.Rx;
66-
...
67-
{
68-
use(new Rx());
69-
70-
get("/1", () -> Observable...)
71-
.map(Rx.rx());
72-
73-
get("/2", () -> Observable...)
74-
.map(Rx.rx());
75-
....
76-
77-
get("/N", () -> Observable...)
78-
.map(Rx.rx());
79-
}
80-
```
81-
82-
This is better than written N routes using the [Deferred API]({{defdocs}}/Deferred.html)... but still there is one more option to help you (and your fingers) to right less code:
83-
84-
```java
85-
...
86-
import org.jooby.rx.Rx;
87-
...
88-
{
89-
use(new Rx());
90-
91-
with(() -> {
92-
93-
get("/1", req -> Observable...);
94-
get("/2", req -> Observable...);
95-
....
96-
get("/N", req -> Observable...);
97-
98-
}).map(Rx.rx());
99-
100-
}
101-
```
102-
103-
**Beautiful, hugh?**
104-
105-
The [with]({{defdocs}}/Routes.html#with-java.lang.Runnable-) operator let you group any number of routes and apply common attributes and/or operator to all them!!!
106-
10760
## rx()+scheduler
10861

10962
You can provide a ```Scheduler``` to the [Rx.rx()]({{defdocs}}/rx/Rx.html#rx--) operator:

0 commit comments

Comments
 (0)