io.reactivex.rxjava3.core.SingleOnSubscribe Java Examples

The following examples show how to use io.reactivex.rxjava3.core.SingleOnSubscribe. 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 vote down vote up
/**
 * 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: DefaultSingle.java    From zap-android with MIT License 4 votes vote down vote up
public static <T> Single<T> createDefault(@NonNull SingleOnSubscribe<T> singleOnSubscribe) {
    return create(singleOnSubscribe).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
}