当前位置: 首页>>代码示例>>Java>>正文


Java ObservableEmitter.onNext方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:qiaodashaoye,项目名称:SuperHttp,代码行数:20,代码来源:ApiCache.java

示例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();
    }
}
 
开发者ID:xiaoyaoyou1212,项目名称:XSnow,代码行数:20,代码来源:ApiCache.java

示例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));
}
 
开发者ID:I60R,项目名称:ActivityRx,代码行数:28,代码来源:ActivityObservableBehavior.java

示例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();
        }
    }));
}
 
开发者ID:btrautmann,项目名称:RxFirestore,代码行数:26,代码来源:DocumentSnapshotsOnSubscribe.java

示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:RxDownload.java

示例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();
    }
}
 
开发者ID:changjiashuai,项目名称:RxJava2-Android-Sample,代码行数:9,代码来源:SimpleExampleActivity.java

示例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();
}
 
开发者ID:quangctkm9207,项目名称:rxjava-family,代码行数:12,代码来源:RxAndroidActivity.java

示例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);
}
 
开发者ID:konmik,项目名称:rxstate,代码行数:12,代码来源:RxState.java

示例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);
    }
  }
}
 
开发者ID:seven332,项目名称:Stage,代码行数:11,代码来源:SceneLifecycleListener.java

示例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();
}
 
开发者ID:greyfoxit,项目名称:RxNetwork,代码行数:13,代码来源:PreLollipopNetworkObservingStrategy.java

示例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);
    }
  };
}
 
开发者ID:pwittchen,项目名称:ReactiveAirplaneMode,代码行数:16,代码来源:ReactiveAirplaneMode.java

示例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();
        }
    }
}
 
开发者ID:graphql-java,项目名称:graphql-java-subscription-example,代码行数:10,代码来源:StockTickerPublisher.java

示例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;
}
 
开发者ID:davidmoten,项目名称:geotemporal,代码行数:29,代码来源:BTree.java

示例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();
}
 
开发者ID:I60R,项目名称:ActivityRx,代码行数:32,代码来源:Activities.java

示例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();
        }
    }));

}
 
开发者ID:btrautmann,项目名称:RxFirestore,代码行数:28,代码来源:QuerySnapshotsOnSubscribe.java


注:本文中的io.reactivex.ObservableEmitter.onNext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。