代码语言:javascript复制
io.reactivex.rxjava3
rxjava
3.0.3
io.projectreactor
reactor-core
3.3.4.RELEASE
io.projectreactor
reactor-test
3.3.4.RELEASE
test
代码语言:javascript复制Observable.just("werd","ewr")
.doOnNext(i->{
System.out.println("i = " i);
})
//doOnXXX一般是用来组装的时候切入
.doOnCompleted(() -> System.out.println("全部结束"))
.doOnError(p-> System.out.println("p = " p))
//subscribe里面的才是订阅者
.subscribe(new Subscriber(){
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable throwable) {
}
@Override
public void onNext(String s) {
}
});
try {
Object wqer = Single.just("wqer")
.map((Func1) s -> s "0000")
.doOnSuccess(Z -> {
System.out.println("Z = " Z);
}).toBlocking().toFuture().get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
io.reactivex.Single.just("ewrt").subscribe(i->{
System.out.println("i = " i);
});
Mono.just("esrd")
.doOnNext(i-> System.out.println("i = " i))
}