Skip to content

Instantly share code, notes, and snippets.

@flyer88
Last active March 8, 2022 03:44
Show Gist options
  • Save flyer88/5d7129fc2ca9010ff6109a81157fbafa to your computer and use it in GitHub Desktop.
Save flyer88/5d7129fc2ca9010ff6109a81157fbafa to your computer and use it in GitHub Desktop.
如何实现 RxJava 的链式调用 -- map 方法的实现
public interface Api{
void queryPhoto(String query,QueryCallback QueryCallback);
interface QueryCallback{
void onQuerySuccess(List<Photo> photoList);
void onQueryFailed(Exception e);
}
}
public class PhotoUtils{
Api mApi;
public void handlePhotoSync(){
mApi.queryPhoto("flyer", new Api.QueryCallback() {
@Override
public void onQuerySuccess(List<Photo> photoList) {
Photo photo = getBestPhoto(photoList);
String imgUrl = photo.getUrl();
}
@Override
public void onQueryFailed(Exception e) {
ToastUtils.show(e);
}
});
}
}
@flyer88
Copy link
Author

flyer88 commented May 24, 2017

=================================

异步里面还有异步方法,flatMap 待续

=================================

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment