本文整理匯總了Java中io.reactivex.ObservableEmitter.setCancellable方法的典型用法代碼示例。如果您正苦於以下問題:Java ObservableEmitter.setCancellable方法的具體用法?Java ObservableEmitter.setCancellable怎麽用?Java ObservableEmitter.setCancellable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.reactivex.ObservableEmitter
的用法示例。
在下文中一共展示了ObservableEmitter.setCancellable方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addEmitter
import io.reactivex.ObservableEmitter; //導入方法依賴的package包/類
public void addEmitter(@NonNull final ObservableEmitter<Integer> emitter) {
emitterList.add(emitter);
emitter.setCancellable(new Cancellable() {
@Override
public void cancel() throws Exception {
emitterList.remove(emitter);
}
});
emitMissingLifecycle(emitter);
}
示例2: subscribe
import io.reactivex.ObservableEmitter; //導入方法依賴的package包/類
@Override
public void subscribe(ObservableEmitter<RealmResults<T>> emitter) throws Exception {
// Initial element.
emitter.onNext(realmResults);
// We don't catch changes without the resulst set since our adapter does this automatically.
// Notify on changes.
RealmChangeListener<RealmResults<T>> changeListener = element -> emitter.onNext(element);
realmResults.addChangeListener(changeListener);
// Make sure we don't listen to the changes when we are no longer interested.
emitter.setCancellable(() -> realmResults.removeChangeListener(changeListener));
}
示例3: subscribe
import io.reactivex.ObservableEmitter; //導入方法依賴的package包/類
@Override
public void subscribe(ObservableEmitter<STATE> emitter) throws Exception {
//the internal listener to the store.
Store.StateChangeListener<STATE> listener =
emitter::onNext;
emitter.setCancellable(() -> store.unsubscribe(listener));
store.subscribe(listener);
}
示例4: subscribe
import io.reactivex.ObservableEmitter; //導入方法依賴的package包/類
@Override
public void subscribe(final ObservableEmitter<RxNetworkInfo> emitter) throws Exception {
broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
emitter.onNext(RxNetworkInfo.create(context));
}
};
emitter.setCancellable(new StrategyCancellable());
register();
}
示例5: subscribe
import io.reactivex.ObservableEmitter; //導入方法依賴的package包/類
@Override
public void subscribe(final ObservableEmitter<RxNetworkInfo> upstream) throws Exception {
networkCallback = new StrategyNetworkCallback(upstream);
upstream.setCancellable(new StrategyCancellable());
register();
}
示例6: subscribe
import io.reactivex.ObservableEmitter; //導入方法依賴的package包/類
@Override
public void subscribe(final ObservableEmitter<RxNetworkInfo> upstream) throws Exception {
upstream.setCancellable(new StrategyCancellable());
registerIdleModeReceiver(upstream);
registerNetworkCallback(upstream);
}