當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。