Java Code Examples for io.reactivex.rxjava3.core.Single#create()
The following examples show how to use
io.reactivex.rxjava3.core.Single#create() .
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: Rx3Apollo.java From apollo-android with MIT License | 6 votes |
/** * Converts an {@link ApolloStoreOperation} to a Single. * * @param operation the ApolloStoreOperation to convert * @param <T> the value type * @return the converted Single */ @NotNull @CheckReturnValue public static <T> Single<T> from(@NotNull final ApolloStoreOperation<T> operation) { checkNotNull(operation, "operation == null"); return Single.create(new SingleOnSubscribe<T>() { @Override public void subscribe(final SingleEmitter<T> emitter) { operation.enqueue(new ApolloStoreOperation.Callback<T>() { @Override public void onSuccess(T result) { emitter.onSuccess(result); } @Override public void onFailure(Throwable t) { emitter.onError(t); } }); } }); }
Example 2
Source File: CatnipShardImpl.java From catnip with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nonnull @Override public Single<ShardConnectState> connect() { if(connected) { return Single.error(new IllegalStateException("Cannot connect shard twice, redeploy it.")); } connected = true; final var result = Single.<ShardConnectState>create(emitter -> message = emitter); connectSocket(); return result; }
Example 3
Source File: RxQuery.java From objectbox-java with Apache License 2.0 | 5 votes |
/** * The returned Single emits one Query result as a List. */ public static <T> Single<List<T>> single(final Query<T> query) { return Single.create(emitter -> { query.subscribe().single().observer(data -> { if (!emitter.isDisposed()) { emitter.onSuccess(data); } }); // no need to cancel, single never subscribes }); }
Example 4
Source File: RequestContextAssemblyTest.java From armeria with Apache License 2.0 | 5 votes |
private static Single<String> single(String input) { RequestContext.current(); return Single.create(emitter -> { RequestContext.current(); emitter.onSuccess(input); }); }
Example 5
Source File: DataServiceImpl.java From java-11-examples with Apache License 2.0 | 4 votes |
@Override public Single<DataItem> getSingle(SingleDataQuery dataQuery) { return Single.create(new SingleOnSubscribeDataProducer(executor, dataQuery)); }