Java 类io.reactivex.MaybeTransformer 实例源码

项目:RxLog    文件:RxLog.java   
/**
 * Creates transform operator, which logs defined events in observable's lifecycle
 * @param msg     message
 * @param bitMask bitmask of events which you want to log
 * @param <T>     type
 * @return transformer
 */
public static <T> MaybeTransformer<T, T> logMaybe(final String msg, final int bitMask) {
    return upstream -> {
        if ((bitMask & LOG_SUBSCRIBE) > 0) {
            upstream = upstream.compose(mLogSubscribe(msg));
        }
        if ((bitMask & LOG_ERROR) > 0) {
            upstream = upstream.compose(mLogError(msg));
        }
        if ((bitMask & LOG_NEXT_DATA) > 0) {
            upstream = upstream.compose(mLogSuccess(msg));
        } else if ((bitMask & LOG_NEXT_EVENT) > 0) {
            upstream = upstream.compose(mLogSuccessEvent(msg));
        }
        if ((bitMask & LOG_COMPLETE) > 0) {
            upstream = upstream.compose(mLogComplete(msg));
        }
        if ((bitMask & LOG_DISPOSE) > 0) {
            upstream = upstream.compose(mLogDispose(msg));
        }
        return upstream;
    };
}
项目:bigbang    文件:Controller.java   
/**
 * Provides the Io schedule {@link Maybe} transformation.
 * Subscribes the stream to Io bound {@link Schedulers} and observes it in the {Android main thread.
 *
 * @return The stream with the schedule transformation
 */
@CheckResult
@NonNull
protected <T> MaybeTransformer<T, T> applyMaybeIoSchedulers() {
  //noinspection unchecked
  return (MaybeTransformer<T, T>) maybeIoTransformer;
}
项目:EasyMVP    文件:MaybeUseCase.java   
public MaybeUseCase(final UseCaseExecutor useCaseExecutor,
                    final PostExecutionThread postExecutionThread) {
    super(useCaseExecutor, postExecutionThread);
    schedulersTransformer = new MaybeTransformer<R, R>() {
        @Override
        public Maybe<R> apply(Maybe<R> single) {
            return single.subscribeOn(useCaseExecutor.getScheduler())
                    .observeOn(postExecutionThread.getScheduler());
        }
    };
}
项目:UseCases    文件:LifecycleRxJavaBinder.java   
public static <T> MaybeTransformer<T, T> applyMaybe(LifecycleOwner lifecycleOwner) {
    return maybe -> {
        LiveData<T> liveData = LiveDataReactiveStreams.fromPublisher(maybe.toFlowable());
        return Flowable.fromPublisher(LiveDataReactiveStreams
                .toPublisher(lifecycleOwner, liveData)).firstElement();
    };
}
项目:RxLog    文件:RxLog.java   
private static <T> MaybeTransformer<T, T> mLogSuccess(final String msg) {
    return upstream -> upstream.doOnSuccess(data -> Timber.d("[onSuccess] %s %s [Thread:%s]", msg, data, Thread.currentThread().getName()));
}
项目:RxLog    文件:RxLog.java   
private static <T> MaybeTransformer<T, T> mLogSuccessEvent(final String msg) {
    return upstream -> upstream.doOnSuccess(x -> Timber.d("[onSuccess] %s [Thread:%s]", msg, Thread.currentThread().getName()));
}
项目:RxLog    文件:RxLog.java   
private static <T> MaybeTransformer<T, T> mLogError(final String msg) {
    final Function<Throwable, String> message = e -> e.getMessage() != null ? e.getMessage() : e.getClass().getSimpleName();
    return upstream -> upstream.doOnError(e -> Timber.e("[onError] %s - %s", msg, message.apply(e)));
}
项目:RxLog    文件:RxLog.java   
private static <T> MaybeTransformer<T, T> mLogComplete(final String msg) {
    return upstream -> upstream.doOnComplete(() -> Timber.v("[onComplete] %s [Thread:%s]", msg, Thread.currentThread().getName()));
}
项目:RxLog    文件:RxLog.java   
private static <T> MaybeTransformer<T, T> mLogSubscribe(final String msg) {
    return upstream -> upstream.doOnSubscribe(disposable -> Timber.v("[subscribe] %s [Thread:%s]", msg, Thread.currentThread().getName()));
}
项目:RxLog    文件:RxLog.java   
private static <T> MaybeTransformer<T, T> mLogDispose(final String msg) {
    return upstream -> upstream.doOnDispose(() -> Timber.v("[dispose] %s", msg));
}
项目:Phoenix-for-VK    文件:RxUtils.java   
public static <T> MaybeTransformer<T, T> applyMaybeIOToMainSchedulers() {
    return upstream -> upstream
            .subscribeOn(Schedulers.io())
            .observeOn(Injection.provideMainThreadScheduler());
}
项目:LifecycleAwareRx    文件:LifecycleBinder.java   
public static <T> MaybeTransformer<T, T> bind(@NonNull LifecycleOwner lifecycleOwner,
                                              @NonNull MaybeObserver<T> observer) {
    return new LifecycleTransformer<>(lifecycleOwner, new MaybeWithObserver<>(observer));
}
项目:EasyMVP    文件:MaybeUseCase.java   
private MaybeTransformer<? super R, ? extends R> getSchedulersTransformer() {
    return schedulersTransformer;
}
项目:OpenLinkWith    文件:SchedulingStrategy.java   
public <T> MaybeTransformer<T, T> forMaybe() {
    return maybe -> maybe
            .subscribeOn(executor)
            .observeOn(notifier);
}
项目:vertx-rx    文件:MaybeHelper.java   
public static <T> MaybeTransformer<Buffer, T> unmarshaller(Class<T> mappedType) {
  return new MaybeUnmarshaller<>(java.util.function.Function.identity(), mappedType);
}
项目:vertx-rx    文件:MaybeHelper.java   
public static <T> MaybeTransformer<Buffer, T> unmarshaller(TypeReference<T> mappedTypeRef) {
  return new MaybeUnmarshaller<>(java.util.function.Function.identity(), mappedTypeRef);
}
项目:vertx-rx    文件:MaybeHelper.java   
public static <T> MaybeTransformer<Buffer, T> unmarshaller(Class<T> mappedType, ObjectMapper mapper) {
  return new MaybeUnmarshaller<>(java.util.function.Function.identity(), mappedType, mapper);
}
项目:vertx-rx    文件:MaybeHelper.java   
public static <T> MaybeTransformer<Buffer, T> unmarshaller(TypeReference<T> mappedTypeRef, ObjectMapper mapper) {
  return new MaybeUnmarshaller<>(java.util.function.Function.identity(), mappedTypeRef, mapper);
}
项目:vertx-rx    文件:MaybeHelper.java   
public static <T> MaybeTransformer<Buffer, T> unmarshaller(Class<T> mappedType) {
  return new MaybeUnmarshaller<>(Buffer::getDelegate, mappedType);
}
项目:vertx-rx    文件:MaybeHelper.java   
public static <T> MaybeTransformer<Buffer, T> unmarshaller(TypeReference<T> mappedTypeRef) {
  return new MaybeUnmarshaller<>(Buffer::getDelegate, mappedTypeRef);
}
项目:vertx-rx    文件:MaybeHelper.java   
public static <T> MaybeTransformer<Buffer, T> unmarshaller(Class<T> mappedType, ObjectMapper mapper) {
  return new MaybeUnmarshaller<>(Buffer::getDelegate, mappedType, mapper);
}
项目:vertx-rx    文件:MaybeHelper.java   
public static <T> MaybeTransformer<Buffer, T> unmarshaller(TypeReference<T> mappedTypeRef, ObjectMapper mapper) {
  return new MaybeUnmarshaller<>(Buffer::getDelegate, mappedTypeRef, mapper);
}