Call same retrofit method sequentially for result using RxJava

半腔热情 提交于 2019-12-12 02:54:29

问题


Complete novice with RxJava here. So please bear with me.

I have a Retrofit API which will upload a file. Looks like below

@Multipart
@POST("api")
Observable<ImageUploadResponse> uploadImage(@Part("") MultipartBody.Part body);

Also I have an ArrayList with Uri that I need to upload. When I went through the reactive tutorials, I saw that using "Observable.from" can help me in calling the API sequentially.

Can some one please help me how to read the response from the API every time the API returns a response. My sudo code looks something like below

Observable.from(imageStorageList)
          .map(uri -> new ImageUploadHelper().uploadImage(new File(uri.getPath())))
           .subscribe(imageUploadResponseObservable -> {

                };

I am really not sure how to capture the response inside the subscribe lambda expression. Any help is highly appreciated

来源:https://stackoverflow.com/questions/36824727/call-same-retrofit-method-sequentially-for-result-using-rxjava

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!