Skip to content

Commit 17a00d6

Browse files
committed
reactor
1 parent c636aab commit 17a00d6

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
<artifactId>reactive-streams</artifactId>
4646
<version>1.0.4</version>
4747
</dependency>
48+
<dependency>
49+
<groupId>io.projectreactor</groupId>
50+
<artifactId>reactor-core</artifactId>
51+
<version>3.4.23</version>
52+
</dependency>
4853
</dependencies>
4954

5055
</project>

src/main/java/concurrency/reactive/PubSub.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class PubSub {
1313
pub -> [Data1] -> mapPub (operator) -> [Data2] -> sub
1414
*/
1515
public static void main(String[] args) {
16-
Publisher<Integer> pub = streamPublisher(Stream.iterate(1, i -> i + 1) );
16+
Publisher<Integer> pub = streamPublisher(Stream.iterate(1, i -> i + 1));
1717
Publisher<Integer> pub1= mapPub(pub, i -> i * 10);
1818
// Publisher<Integer> pub2 = reducePub(pub1, 0, Integer::sum);
1919
var pub2 = reducePub(pub1, new StringBuilder(), (sb, i) -> sb.append(i).append(". "));
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package concurrency.reactive;
2+
3+
import reactor.core.publisher.Flux;
4+
5+
public class ReactorEx {
6+
7+
/*
8+
Reactor is a reactive library which implements Reactive Streams Specification. Spring choose reactor by default.
9+
*/
10+
public static void main(String[] args) {
11+
Flux.range(1, 10)
12+
.map(i -> i * 10)
13+
.reduce(Integer::sum)
14+
.subscribe(System.out::println);
15+
}
16+
}

0 commit comments

Comments
 (0)