【发布时间】:2017-08-11 08:58:08
【问题描述】:
如何在 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
}
});
【问题讨论】:
-
请阅读this。
标签: android rx-android rx-java2