-
-
Notifications
You must be signed in to change notification settings - Fork 57
/
ReactorVsRx.java
60 lines (47 loc) · 1.99 KB
/
ReactorVsRx.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package rx.utils;
import org.junit.Test;
import reactor.core.publisher.Flux;
import rx.Observable;
import java.lang.reflect.Method;
import java.util.List;
/**
* This class is meant to be used as constantClass comparator between RxJava and Spring Reactor
*/
public class ReactorVsRx {
@Test
public void operators() {
List<String> rxOperatorsList = Observable.from(Observable.class.getMethods())
.filter(m -> Observable.class.isAssignableFrom(m.getReturnType()))
.map(Method::getName)
.distinct()
.toSortedList().toBlocking().first();
List<String> reactorOperatorsList = Flux.fromArray(Flux.class.getMethods())
.filter(m -> Flux.class.isAssignableFrom(m.getReturnType()))
.map(Method::getName)
.distinct()
.collectList().block();
System.out.println(String.format("RX OPERATORS Nº:%s VS REACTOR OPERATORS Nº:%s",rxOperatorsList.size(), reactorOperatorsList.size()));
rxOperators();
reactorOperators();
}
@Test
public void rxOperators() {
Observable.from(Observable.class.getMethods())
.filter(m -> Observable.class.isAssignableFrom(m.getReturnType()))
.map(Method::getName)
.distinct()
.toSortedList()
.doOnNext(list -> System.out.println("RX OPERATORS:"+list.size()))
.subscribe(System.out::println);
}
@Test
public void reactorOperators() {
Flux.fromArray(Flux.class.getMethods())
.filter(m -> Flux.class.isAssignableFrom(m.getReturnType()))
.map(Method::getName)
.distinct()
.collectList()
.doOnNext(list -> System.out.println("REACTOR OPERATORS:"+list.size()))
.subscribe(System.out::println);
}
}