You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!"));
31
33
}
32
34
```
33
35
@@ -51,53 +53,6 @@ Previous example is translated to:
51
53
52
54
Translation is done with the [Reactor.reactor()]({{defdocs}}/reactor/Reactor.html#reactor--) route operator. If you are a <ahref="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).
53
55
54
-
## reactor()
55
-
56
-
We just learn that we are not force to learn a new API, just write <ahref="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
-
importorg.jooby.reactor.Reactor;
63
-
...
64
-
{
65
-
use(newReactor());
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
-
importorg.jooby.reactor.Reactor;
84
-
...
85
-
{
86
-
use(newReactor());
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!!!
Copy file name to clipboardExpand all lines: md/doc/rxjava/rxjava.md
+5-52Lines changed: 5 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,8 +29,11 @@ import org.jooby.rx.Rx;
29
29
{
30
30
use(newRx());
31
31
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
+
34
37
}
35
38
```
36
39
@@ -54,56 +57,6 @@ Previous example is translated to:
54
57
55
58
Translation is done with the [Rx.rx()]({{defdocs}}/rx/Rx.html#rx--) route operator. If you are a <ahref="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).
56
59
57
-
## rx()
58
-
59
-
We just learn that we are not force to learn a new API, just write <ahref="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
-
importorg.jooby.rx.Rx;
66
-
...
67
-
{
68
-
use(newRx());
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
-
importorg.jooby.rx.Rx;
87
-
...
88
-
{
89
-
use(newRx());
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
-
107
60
## rx()+scheduler
108
61
109
62
You can provide a ```Scheduler``` to the [Rx.rx()]({{defdocs}}/rx/Rx.html#rx--) operator:
0 commit comments