Java Code Examples for io.reactivex.FlowableEmitter#onComplete()
The following examples show how to use
io.reactivex.FlowableEmitter#onComplete() .
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: RxEasyHttpManager.java From EasyHttp with Apache License 2.0 | 6 votes |
@Override public void subscribe(FlowableEmitter<T> e) throws Exception { try { Response response = call.execute(); if (!e.isCancelled()) { if (response.isSuccessful()) { e.onNext(rxEasyConverter.convert(response.body().string())); } else { e.onError(new Throwable("response is unsuccessful")); } } } catch (Throwable t) { if (!e.isCancelled()) { e.onError(t); } } finally { e.onComplete(); } }
Example 2
Source File: ObserveQuery.java From vault with Apache License 2.0 | 6 votes |
@Override public void subscribe(FlowableEmitter<T> flowableEmitter) throws Exception { try { FetchQuery<T> fetchQuery = query.vault().fetch(query.type()); fetchQuery.setParams(query.params()); List<T> items = fetchQuery.all(locale); for (T item : items) { if (flowableEmitter.isCancelled()) { return; } flowableEmitter.onNext(item); } } catch (Throwable t) { if (!flowableEmitter.isCancelled()) { flowableEmitter.onError(t); } return; } if (!flowableEmitter.isCancelled()) { flowableEmitter.onComplete(); } }
Example 3
Source File: RxJavaUtils.java From Collection-Android with MIT License | 5 votes |
@NonNull private static <T, R> RxTaskOnSubscribe<RxAsyncTask<T, R>> getRxAsyncTaskOnSubscribe(@NonNull final RxAsyncTask<T, R> rxTask) { return new RxTaskOnSubscribe<RxAsyncTask<T, R>>(rxTask) { @Override public void subscribe(FlowableEmitter<RxAsyncTask<T, R>> emitter) throws Exception { RxAsyncTask<T, R> task = getTask(); task.setOutData(task.doInIOThread(task.getInData())); //在io线程工作 emitter.onNext(task); emitter.onComplete(); } }; }
Example 4
Source File: FlowableOnSubscribeExecuteAsBlocking.java From storio with Apache License 2.0 | 5 votes |
@Override public void subscribe(@NonNull FlowableEmitter<Result> emitter) throws Exception { try { emitter.onNext(preparedOperation.executeAsBlocking()); emitter.onComplete(); } catch (Exception e) { emitter.onError(e); } }
Example 5
Source File: FlowableOnSubscribeExecuteAsBlockingOptional.java From storio with Apache License 2.0 | 5 votes |
@Override public void subscribe(@NonNull FlowableEmitter<Optional<Result>> emitter) throws Exception { try { final Result value = preparedOperation.executeAsBlocking(); emitter.onNext(Optional.of(value)); emitter.onComplete(); } catch (Exception e) { emitter.onError(e); } }