I have rest api.
@Get("/serveraction")
public Observable<String> myRequest(@Query("Data") String data);
I know, that okhttp has canceling functionality(by request object, by tag), but don't know how use it with retrofit and rxjava. What is the best way to realize canceling mechanism for network tasks with retrofit and rxjava?
You can use the standard RxJava2 cancelling mechanism Disposable.
Observable<String> o = retrofit.getObservable(..);
Disposable d = o.subscribe(...);
// later when not needed
d.dispose();
Retrofit RxJava call adapter will redirect this to okHttp's cancel.