如何在RxJava2中取消订阅observable或订阅?或者我真的需要吗?
//Initialising Obersvable
Observable<SearchSuggestions> observable = NetworkContext.api.getSearch("");
//subscribing obersvable on another thread and observing on main thread
observable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<SearchSuggestions>() {
@Override
public void accept(SearchSuggestions searchSuggestions) throws Exception {
// here I receive the fetched results
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
//here the error
}
});