本文整理汇总了Java中io.reactivex.ObservableEmitter.onNext方法的典型用法代码示例。如果您正苦于以下问题:Java ObservableEmitter.onNext方法的具体用法?Java ObservableEmitter.onNext怎么用?Java ObservableEmitter.onNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.ObservableEmitter
的用法示例。
在下文中一共展示了ObservableEmitter.onNext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: subscribe
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(ObservableEmitter<T> subscriber) throws Exception {
try {
T data = execute();
if (!subscriber.isDisposed() && data != null) {
subscriber.onNext(data);
}
} catch (Throwable e) {
Exceptions.throwIfFatal(e);
if (!subscriber.isDisposed()) {
subscriber.onError(e);
}
return;
}
if (!subscriber.isDisposed()) {
subscriber.onComplete();
}
}
示例2: subscribe
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(ObservableEmitter<T> subscriber) throws Exception {
try {
T data = execute();
if (!subscriber.isDisposed() && data != null) {
subscriber.onNext(data);
}
} catch (Throwable e) {
ViseLog.e(e);
Exceptions.throwIfFatal(e);
if (!subscriber.isDisposed()) {
subscriber.onError(e);
}
return;
}
if (!subscriber.isDisposed()) {
subscriber.onComplete();
}
}
示例3: subscribe
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
/**
* Called when some subscriber subscribes to A events.
*/
@Override
public void subscribe(@NonNull ObservableEmitter<State<A>> emitter) throws Exception {
State<? extends Activity> current = null;
for (State<? extends Activity> state : states) {
if (state.id.equals(component)) {
current = state;
break;
}
}
if (current == null) {
current = new State<>(component, On.ABSENT, null, null);
}
LinkedHashSet<ObservableEmitter> queue = emitters.get(component);
if (queue == null) {
queue = new LinkedHashSet<>(5);
}
this.emitter = emitter;
queue.add(emitter);
emitters.put(component, queue);
emitter.onNext(apply(current));
}
示例4: subscribe
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(final ObservableEmitter<DocumentSnapshot> emitter) throws Exception {
final EventListener<DocumentSnapshot> listener = new EventListener<DocumentSnapshot>() {
@Override
public void onEvent(DocumentSnapshot documentSnapshot, FirebaseFirestoreException e) {
if (!emitter.isDisposed()) {
if (e == null) {
emitter.onNext(documentSnapshot);
} else {
emitter.onError(e);
}
}
}
};
registration = documentReference.addSnapshotListener(listener);
emitter.setDisposable(Disposables.fromAction(new Action() {
@Override
public void run() throws Exception {
registration.remove();
}
}));
}
示例5: doCall
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
private void doCall(GeneralObservableCallback callback, ObservableEmitter<Object> emitter) {
if (callback != null) {
try {
callback.call();
} catch (Exception e) {
emitter.onError(e);
}
}
emitter.onNext(object);
emitter.onComplete();
}
示例6: subscribe
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(ObservableEmitter<String> e) throws Exception {
if (getStrFromNetwork() != null) {
e.onNext(getStrFromNetwork());
} else {
e.onComplete();
}
}
示例7: subscribe
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
@Override public void subscribe(@NonNull ObservableEmitter<Integer> emitter) throws Exception {
// Suppose we have a long task which is simulated by using Thread.sleep().
// We need to run it in the background to avoid blocking the main thread.
emitter.onNext(1);
Thread.sleep(1000);
emitter.onNext(2);
Thread.sleep(1000);
emitter.onNext(3);
Thread.sleep(1000);
emitter.onComplete();
}
示例8: onSubscribeImmediate
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
private void onSubscribeImmediate(ObservableEmitter<T> emitter) {
T emit;
synchronized (this) {
emit = value;
}
emitter.onNext(emit);
synchronized (this) {
emitters.add(emitter);
}
setDisposable(emitter);
}
示例9: emit
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
private void emit(ObservableEmitter<Integer> emitter, int lifecycle) {
if (!emitter.isDisposed()) {
try {
emitter.onNext(lifecycle);
} catch (Throwable t) {
Exceptions.throwIfFatal(t);
RxJavaPlugins.onError(t);
}
}
}
示例10: 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();
}
示例11: createBroadcastReceiver
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
/**
* Creates BroadcastReceiver for monitoring airplane mode
*
* @param emitter for RxJava
* @return BroadcastReceiver
*/
@NonNull protected BroadcastReceiver createBroadcastReceiver(
@NonNull final ObservableEmitter<Boolean> emitter) {
return new BroadcastReceiver() {
@Override public void onReceive(final Context context, final Intent intent) {
boolean isAirplaneModeOn = intent.getBooleanExtra(INTENT_EXTRA_STATE, false);
emitter.onNext(isAirplaneModeOn);
}
};
}
示例12: emitStocks
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
private void emitStocks(ObservableEmitter<StockPriceUpdate> emitter, List<StockPriceUpdate> stockPriceUpdates) {
for (StockPriceUpdate stockPriceUpdate : stockPriceUpdates) {
try {
emitter.onNext(stockPriceUpdate);
} catch (RuntimeException rte) {
rte.printStackTrace();
}
}
}
示例13: range
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
private boolean range(Node<Key, Value> x, Key lower, Key upper, int ht,
ObservableEmitter<Value> emitter) {
if (ht == 0) {
// external node
for (int j = 0; j < x.numEntries(); j++) {
if (emitter.isDisposed()) {
return false;
}
if (geq(x.key(j), lower) && less(x.key(j), upper)) {
emitter.onNext(x.value(j));
}
}
} else {
// internal node
for (int j = 0; j < x.numEntries(); j++) {
if (j + 1 == x.numEntries() || (less(lower, x.key(j + 1)))) {
if (emitter.isDisposed()) {
return false;
}
if (!range(x.next(j), lower, upper, ht - 1, emitter)) {
return false;
}
}
}
}
return true;
}
示例14: setState
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static void setState(
@NonNull String id,
@NonNull On on,
@Nullable Activity activity,
@Nullable Bundle bundle) {
State<? extends Activity> newState = new State<>(id, on, activity, bundle);
EVENTS.onNext(newState);
Iterator<State<? extends Activity>> iterator = STATES.iterator();
while (iterator.hasNext()) {
if (iterator.next().id.equals(id)) {
iterator.remove();
break;
}
}
if (newState.on != On.DESTROY) {
STATES.add(newState);
}
for (Map.Entry<String, LinkedHashSet<ObservableEmitter>> subscription : EMITTERS.entrySet()) {
if (subscription.getKey().equals(id)) {
BUFFER.addAll(subscription.getValue());
}
}
for (ObservableEmitter emitter : BUFFER) {
emitter.onNext(newState);
}
BUFFER.clear();
}
示例15: subscribe
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(final ObservableEmitter<QuerySnapshot> emitter) throws Exception {
final EventListener<QuerySnapshot> listener = new EventListener<QuerySnapshot>() {
@Override
public void onEvent(QuerySnapshot querySnapshot, FirebaseFirestoreException e) {
if (!emitter.isDisposed()) {
if (e == null) {
emitter.onNext(querySnapshot);
} else {
emitter.onError(e);
}
}
}
};
registration = query.addSnapshotListener(listener);
emitter.setDisposable(Disposables.fromAction(new Action() {
@Override
public void run() throws Exception {
registration.remove();
}
}));
}