我已经开始深入研究 retrolambda 和 rxjava。我自己转换了一些表达式,但其中一些我无法转换。我在我的项目中添加了 retrolambda。这里是示例
public Observable<ImmutableList<Repository>> getUsersRepositories() {
return githubApiService.getUsersRepositories(user.login)
.map(repositoryResponses -> {
final ImmutableList.Builder<Repository> listBuilder = ImmutableList.builder();
for (RepositoryResponse repositoryResponse : repositoryResponses) {
Repository repository = new Repository();
repository.id = repositoryResponse.id;
repository.name = repositoryResponse.name;
repository.url = repositoryResponse.url;
listBuilder.add(repository);
}
return listBuilder.build();
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
但我不知道如何转换这种和平的代码:
obs.subscribe(new Observer<List<Integer>>() {
public void onCompleted() {
System.out.println("completed");
}
public void onError(Throwable e) {
System.out.println("failure");
}
public void onNext(List<Integer> value) {
System.out.println("onnext=" + value);
}
});