Java Code Examples for io.reactivex.ObservableEmitter#tryOnError()
The following examples show how to use
io.reactivex.ObservableEmitter#tryOnError() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScanOperation.java From RxAndroidBle with Apache License 2.0 | 6 votes |
@Override final protected void protectedRun(final ObservableEmitter<SCAN_RESULT_TYPE> emitter, QueueReleaseInterface queueReleaseInterface) { final SCAN_CALLBACK_TYPE scanCallback = createScanCallback(emitter); try { emitter.setCancellable(new Cancellable() { @Override public void cancel() { RxBleLog.i("Scan operation is requested to stop."); stopScan(rxBleAdapterWrapper, scanCallback); } }); RxBleLog.i("Scan operation is requested to start."); boolean startLeScanStatus = startScan(rxBleAdapterWrapper, scanCallback); if (!startLeScanStatus) { emitter.tryOnError(new BleScanException(BleScanException.BLUETOOTH_CANNOT_START)); } } catch (Throwable throwable) { RxBleLog.w(throwable, "Error while calling the start scan function"); emitter.tryOnError(new BleScanException(BleScanException.BLUETOOTH_CANNOT_START, throwable)); } finally { queueReleaseInterface.release(); } }
Example 2
Source File: DisposableUtil.java From RxAndroidBle with Apache License 2.0 | 6 votes |
public static <T> DisposableObserver<T> disposableObserverFromEmitter(final ObservableEmitter<T> emitter) { return new DisposableObserver<T>() { @Override public void onNext(T t) { emitter.onNext(t); } @Override public void onError(Throwable e) { emitter.tryOnError(e); } @Override public void onComplete() { emitter.onComplete(); } }; }
Example 3
Source File: DisposableUtil.java From RxAndroidBle with Apache License 2.0 | 5 votes |
public static <T> DisposableSingleObserver<T> disposableSingleObserverFromEmitter(final ObservableEmitter<T> emitter) { return new DisposableSingleObserver<T>() { @Override public void onSuccess(T t) { emitter.onNext(t); emitter.onComplete(); } @Override public void onError(Throwable e) { emitter.tryOnError(e); } }; }