I am new in retrofit/rxjava-android
Someone told me that, it is best practice if I will cancel the request if the call is not yet finished and the user leaves the activity page.
I am having problem where/how to cancel it.
Here's my code, it is working properly.
Observable<List<MyObject>> call;
public void getStaticMessages() {
call = restInterface.loginURL();
call.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<List<MyObject>>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
Log.d("LOGGER", "error");
}
@Override
public void onNext(List<MyObject> myObjects) {
Log.d("LOGGER", "succcess");
}
});
}