Java 类io.reactivex.annotations.SchedulerSupport 实例源码
项目:RxJava2Extensions
文件:Nono.java
/**
* Blockingly await indefinitely the termination of this Nono and return
* the Throwable if this Nono terminated with an error, null
* otherwise.
* @return the Throwable error of the Nono, null if completed normally
*/
@SchedulerSupport(SchedulerSupport.NONE)
public final Throwable blockingAwait() {
if (this instanceof Callable) {
try {
((Callable<?>)this).call();
return null;
} catch (Throwable ex) {
Exceptions.throwIfFatal(ex);
return ex;
}
}
NonoBlockingAwaitSubscriber s = new NonoBlockingAwaitSubscriber();
subscribe(s);
return s.blockingAwait();
}
项目:RxJava2Extensions
文件:Nono.java
/**
* Blockingly await for the given timeout the termination of this Nono and return
* the Throwable if this Nono terminated with an error, null
* otherwise.
* @param timeout the timeout value
* @param unit the time unit
* @return the Throwable error of the Nono, null if completed normally
*/
@SchedulerSupport(SchedulerSupport.NONE)
public final Throwable blockingAwait(long timeout, TimeUnit unit) {
if (this instanceof Callable) {
try {
((Callable<?>)this).call();
return null;
} catch (Throwable ex) {
Exceptions.throwIfFatal(ex);
return ex;
}
}
ObjectHelper.requireNonNull(unit, "unit is null");
NonoBlockingAwaitSubscriber s = new NonoBlockingAwaitSubscriber();
subscribe(s);
return s.blockingAwait(timeout, unit);
}
项目:RxJava2Extensions
文件:Nono.java
/**
* Create a TestSubscriber, subscribe it to this Nono and return
* the TestSubscriber itself.
* @return the TestSubscriber created
*/
@SchedulerSupport(SchedulerSupport.NONE)
public final TestSubscriber<Void> test() {
TestSubscriber<Void> ts = new TestSubscriber<Void>();
subscribe(ts);
return ts;
}
项目:RxJava2Extensions
文件:Nono.java
/**
* Create a TestSubscriber, optionally cancel it, subscribe it to this Nono and return
* the TestSubscriber itself.
* @param cancelled shoud the TestSubscriber be cancelled before the subscription
* @return the TestSubscriber created
*/
@SchedulerSupport(SchedulerSupport.NONE)
public final TestSubscriber<Void> test(boolean cancelled) {
TestSubscriber<Void> ts = new TestSubscriber<Void>();
if (cancelled) {
ts.cancel();
}
subscribe(ts);
return ts;
}
项目:Java-EX
文件:RxIterator.java
@SchedulerSupport(SchedulerSupport.IO)
public static <T> Iterator<T> toIterator(Observable<T> ob) {
return toIterator(ob, Schedulers.io());
}
项目:Java-EX
文件:RxIterator.java
@SchedulerSupport(SchedulerSupport.IO)
public static <T> Iterator<T> toIterator(Observable<T> ob) {
return toIterator(ob, Schedulers.io());
}
项目:RxJava2Extensions
文件:Nono.java
/**
* Completes after the specified amount of time on the specified scheduler.
* @param delay the delay value
* @param unit the delay time unit
* @param scheduler the scheduler to delay the completion signal
* @return the new Nono instance
*/
@SchedulerSupport(SchedulerSupport.CUSTOM)
public static Nono timer(long delay, TimeUnit unit, Scheduler scheduler) {
ObjectHelper.requireNonNull(unit, "unit is null");
ObjectHelper.requireNonNull(scheduler, "scheduler is null");
return onAssembly(new NonoTimer(delay, unit, scheduler));
}
项目:RxJava2Extensions
文件:Nono.java
/**
* Subscribe with the given subscriber and return the same subscriber, allowing
* chaining methods on it or fluently reusing the instance.
* @param <T> the target value type of the subscriber
* @param <E> the subscriber's (sub)type
* @param subscriber the subscriber to subscribe with, not null
* @return the subscriber
*/
@SchedulerSupport(SchedulerSupport.NONE)
@SuppressWarnings("unchecked")
public final <T, E extends Subscriber<T>> E subscribeWith(E subscriber) {
subscribe((Subscriber<Object>)subscriber);
return subscriber;
}
项目:RxJava2Extensions
文件:Nono.java
/**
* Subscribe to this Nono and execute the given action if this Nono
* completes or call the consumer if this Nono terminates with an error.
* @param onComplete the callback Action to be called when this Nono
* completes
* @param onError the callback Consumer to be called with the terminal
* error.
* @return the Disposable to cancel the subscription
*/
@SchedulerSupport(SchedulerSupport.NONE)
public final Disposable subscribe(Action onComplete, Consumer<? super Throwable> onError) {
ObjectHelper.requireNonNull(onComplete, "onComplete is null");
ObjectHelper.requireNonNull(onError, "onError is null");
NonoLambdaSubscriber s = new NonoLambdaSubscriber(onComplete, onError);
subscribe(s);
return s;
}
项目:RxJava2Extensions
文件:Nono.java
/**
* Completes after the specified amount of time on the computation scheduler.
* @param delay the delay value
* @param unit the delay time unit
* @return the new Nono instance
*/
@SchedulerSupport(SchedulerSupport.COMPUTATION)
public static Nono timer(long delay, TimeUnit unit) {
return timer(delay, unit, Schedulers.computation());
}
项目:RxJava2Extensions
文件:Nono.java
/**
* Subscribe to this Nono and execute the given action if this Nono
* completes.
* @param onComplete the callback Action to be called when this Nono
* completes
* @return the Disposable to cancel the subscription
*/
@SchedulerSupport(SchedulerSupport.NONE)
public final Disposable subscribe(Action onComplete) {
return subscribe(onComplete, Functions.ERROR_CONSUMER);
}