當前位置: 首頁>>代碼示例>>Java>>正文


Java ObservableEmitter.onError方法代碼示例

本文整理匯總了Java中io.reactivex.ObservableEmitter.onError方法的典型用法代碼示例。如果您正苦於以下問題:Java ObservableEmitter.onError方法的具體用法?Java ObservableEmitter.onError怎麽用?Java ObservableEmitter.onError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.reactivex.ObservableEmitter的用法示例。


在下文中一共展示了ObservableEmitter.onError方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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) {
        ViseLog.e(e);
        Exceptions.throwIfFatal(e);
        if (!subscriber.isDisposed()) {
            subscriber.onError(e);
        }
        return;
    }
    if (!subscriber.isDisposed()) {
        subscriber.onComplete();
    }
}
 
開發者ID:xiaoyaoyou1212,項目名稱:XSnow,代碼行數:20,代碼來源:ApiCache.java

示例2: subscribe

import io.reactivex.ObservableEmitter; //導入方法依賴的package包/類
@Override
public void subscribe(@NonNull ObservableEmitter<T> subscriber) throws Exception {
    try {
        T data = execute();
        if (!subscriber.isDisposed()) {
            subscriber.onNext(data);
        }
    } catch (Throwable e) {
        HttpLog.e(e.getMessage());
        if (!subscriber.isDisposed()) {
            subscriber.onError(e);
        }
        Exceptions.throwIfFatal(e);
        //RxJavaPlugins.onError(e);
        return;
    }

    if (!subscriber.isDisposed()) {
        subscriber.onComplete();
    }
}
 
開發者ID:zhou-you,項目名稱:RxEasyHttp,代碼行數:22,代碼來源:RxCache.java

示例3: 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

示例4: subscribe

import io.reactivex.ObservableEmitter; //導入方法依賴的package包/類
@Override public void subscribe(final ObservableEmitter<DataSnapshot> emitter) {
  final ValueEventListener listener = new ValueEventListener() {
    @Override public void onDataChange(DataSnapshot dataSnapshot) {
      if (!emitter.isDisposed()) {
        emitter.onNext(dataSnapshot);
      }
    }

    @Override public void onCancelled(DatabaseError databaseError) {
      if (!emitter.isDisposed()) {
        emitter.onError(databaseError.toException());
      }
    }
  };

  ref.addValueEventListener(listener);
  emitter.setDisposable(Disposables.fromAction(new Action() {
    @Override public void run() throws Exception {
      ref.removeEventListener(listener);
    }
  }));
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:23,代碼來源:DataChangesOnSubscribe.java

示例5: 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

示例6: 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

示例7: 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

示例8: subscribe

import io.reactivex.ObservableEmitter; //導入方法依賴的package包/類
@Override
public void subscribe(final ObservableEmitter<DocumentChange> emitter) throws Exception {
    final EventListener<QuerySnapshot> listener = new EventListener<QuerySnapshot>() {
        @Override
        public void onEvent(QuerySnapshot querySnapshot, FirebaseFirestoreException e) {

            if (!emitter.isDisposed()) {
                if (e == null) {
                    for (DocumentChange change : querySnapshot.getDocumentChanges()) {
                        emitter.onNext(change);
                    }

                } 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,代碼行數:30,代碼來源:DocumentChangesOnSubscribe.java


注:本文中的io.reactivex.ObservableEmitter.onError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。