很新實施與改造的RxJava2,已經實現了一切,並希望得到的結果作爲JSONObejectRxjava2與改造
Map<String, String> requestBody = new HashMap<>();
requestBody.put("username", "xyz");
requestBody.put("password", "abc");
Single<ResponseBody> singleResponse = myService.loginWithParam(requestBody);
singleResponse.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSingleObserver<ResponseBody>() {
@Override
public void onSuccess(ResponseBody response) {
response // this needs to be converted JsonObject
loginResponse(response);
}
@Override
public void onError(Throwable e) {
System.out.println(e.getMessage());
}
});
ResponseBody反應如何轉換此爲JSON對象,可能在網上找不到任何鏈接。
不錯..有什麼用RxJava2的差異使用retrofit.can你解釋如果可能的話。 –
希望這可以幫助你https://medium.com/3xplore/handling-api-calls-using-retrofit-2-and-rxjava-2-1871c891b6ae – John