本文整理匯總了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();
}
}));
}