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
Copy file name to clipboardExpand all lines: README.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,7 @@ Flowable.just("Hello world")
68
68
69
69
RxJava 2 features several base classes you can discover operators on:
70
70
71
-
-`io.reactivex.Flowable`: 0..N flows, supporting Reactive-Streams and backpressure
71
+
-`io.reactivex.Flowable`: 0..N flows, supporting Reactive-Streams and backpressure
72
72
-`io.reactivex.Observable`: 0..N flows, no backpressure
73
73
-`io.reactivex.Single`: a flow of exactly 1 item or an error
74
74
-`io.reactivex.Completable`: a flow without items but only a completion or error signal
@@ -133,7 +133,7 @@ Flowable.range(1, 10)
133
133
.subscribeOn(Schedulers.computation())
134
134
.map(w -> w * w)
135
135
)
136
-
.blockingSubscribe(System.out::println);
136
+
.blockingSubscribe(System.out::println);
137
137
```
138
138
139
139
Practically, paralellism in RxJava means running independent flows and merging their results back into a single flow. The operator `flatMap` does this by first mapping each number from 1 to 10 into its own individual `Flowable`, runs them and merges the computed squares.
@@ -142,11 +142,11 @@ Starting from 2.0.5, there is an *experimental* operator `parallel()` and type `
142
142
143
143
```java
144
144
Flowable.range(1, 10)
145
-
.parallel()
146
-
.runOn(Schedulers.computation())
147
-
.map(v -> v * v)
148
-
.sequential()
149
-
.blockingSubscribe(System.out::println);
145
+
.parallel()
146
+
.runOn(Schedulers.computation())
147
+
.map(v -> v * v)
148
+
.sequential()
149
+
.blockingSubscribe(System.out::println);
150
150
```
151
151
152
152
`flatMap` is a powerful operator and helps in a lot of situations. For example, given a service that returns a `Flowable`, we'd like to call another service with values emitted by the first service:
->System.out.println("Item "+ inventoryItem.getName() +" has demand "+ demand));
161
-
)
162
-
.subscribe();
161
+
)
162
+
.subscribe();
163
163
```
164
164
165
165
Note, however, that `flatMap` doesn't guarantee any order and the end result from the inner flows may end up interleaved. There are alternative operators:
0 commit comments