Skip to content

Instantly share code, notes, and snippets.

@PhamNgocPhi
Created March 13, 2020 09:04
Show Gist options
  • Save PhamNgocPhi/47834bb547f01716496f07ba35a964fd to your computer and use it in GitHub Desktop.
Save PhamNgocPhi/47834bb547f01716496f07ba35a964fd to your computer and use it in GitHub Desktop.
void callApi() {
disposable.add(apiService.callApi()
.doOnSubscribe(it -> {
// thông báo cho view hiển thị loading
})
.doFinally(() -> {
// thông báo cho view ẩn loading vì chúng ta đã call api xong
})
.subscribe(response -> {
// call api success
// làm 1 vài bước biến đổi response hoặc gửi dữ liệu tới view để hiện thị
}, throwable -> {
handleThrowable(throwable);
// thông báo cho view ẩn loading và show lỗi
})
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment