将 RxJava1 代码转换为 RXJava2 给出这个错误,不确定我做错了什么
不存在类型变量 R 的实例,因此 Single> 符合 ObserableSource
API 调用
@GET("/search/users?per_page=2")
Observable<UsersList> searchGithubUsers(@Query("q") String searchTerm);
@GET("/users/{username}")
Observable<User> getUser(@Path("username") String username);
RXJAva1:
public Observable<List<User>> searchUsers(final String searchTerm) {
return Observable.defer(() -> githubUserRestService.searchGithubUsers(searchTerm).concatMap(
usersList -> Observable.from(usersList.getItems())
.concatMap(user -> githubUserRestService.getUser(user.getLogin())).toList()))
.retryWhen(observable -> observable.flatMap(o -> {
if (o instanceof IOException) {
return Observable.just(null);
}
return Observable.error(o);
}));
}
RXJava2
public Observable<List<User>> searchUsers(final String searchTerm) {
return Observable.defer(() -> githubUserRestService.searchGithubUsers(searchTerm).concatMap(
usersList -> Observable.fromIterable(usersList.getItems())
.concatMap(user -> githubUserRestService.getUser(user.getLogin())).toList()))
.retryWhen(observable -> observable.flatMap(o -> {
if (o instanceof IOException) {
return Observable.just(null);
}
return Observable.error(o);
}));
}