本文整理汇总了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);
}