[英]add subscriber to Single observed value
I would like to know how can I add the subscriber for single as shown below in the code. 我想知道如何为代码添加单个订阅者,如下面的代码所示。 when i try to add .subscribe() or .blockingsubscribe() the autocomplete in eclise does not show them
当我尝试添加.subscribe()或.blockingsubscribe()时,eclise中的自动完成功能不会显示它们
code : 代码 :
Single<List<List<Person>>> singles = Single.just(Main.getPersons());
singles
.observeOn(Schedulers.io())
.map(x->System.out.println(x.size()))
Your map function should return something that you want to subscribe on: 您的地图函数应返回您要订阅的内容:
.map(x -> {
System.out.println(x.size());
return ???;
});
You are using the wrong lambda and it throws off your IDE. 您使用了错误的lambda,它会抛出您的IDE。 Try this:
尝试这个:
Single<List<List<Person>>> singles = Single.just(Main.getPersons());
singles
.observeOn(Schedulers.io())
.doOnSuccess(x -> System.out.println(x.size()))
. // <---------------------------------------- now it should bring up the autocomplete
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.