本文整理匯總了Java中io.reactivex.functions.Action.run方法的典型用法代碼示例。如果您正苦於以下問題:Java Action.run方法的具體用法?Java Action.run怎麽用?Java Action.run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.reactivex.functions.Action
的用法示例。
在下文中一共展示了Action.run方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doOnEmpty
import io.reactivex.functions.Action; //導入方法依賴的package包/類
public static <T> FlowableOperator<T, T> doOnEmpty(Action
action) {
return new FlowableOperator<T, T>() {
@Override
public Subscriber<? super T> apply(Subscriber<? super
T> subscriber) throws Exception {
return new DisposableSubscriber<T>() {
boolean isEmpty = true;
@Override
public void onNext(T value) {
isEmpty = false;
subscriber.onNext(value);
}
@Override
public void onError(Throwable t) {
subscriber.onError(t);
}
@Override
public void onComplete() {
if (isEmpty) {
try {
action.run();
} catch (Exception e) {
onError(e);
return;
}
}
subscriber.onComplete();
}
};
}
};
}
示例2: doOnEmpty
import io.reactivex.functions.Action; //導入方法依賴的package包/類
public static <T> ObservableOperator<T, T> doOnEmpty(Action
action) {
return new ObservableOperator<T, T>() {
@Override
public Observer<? super T> apply(Observer<? super T>
observer) throws Exception {
return new DisposableObserver<T>() {
boolean isEmpty = true;
@Override
public void onNext(T value) {
isEmpty = false;
observer.onNext(value);
}
@Override
public void onError(Throwable t) {
observer.onError(t);
}
@Override
public void onComplete() {
if (isEmpty) {
try {
action.run();
} catch (Exception e) {
onError(e);
return;
}
}
observer.onComplete();
}
};
}
};
}
示例3: ifNotPresent
import io.reactivex.functions.Action; //導入方法依賴的package包/類
@Nonnull
public RxOptional<T> ifNotPresent(@Nonnull Action action) {
if (value == null) {
requireNonNull(action);
try {
action.run();
} catch (Exception e) {
e.printStackTrace();
}
}
return this;
}
示例4: invoke
import io.reactivex.functions.Action; //導入方法依賴的package包/類
/**
* invoke an {@link Action} or throw a {@link RuntimeException}
*
* @param action the {@link Action} to invoke
*/
static void invoke(Action action) {
try {
action.run();
} catch (Exception e) {
throw new RuntimeExceptionConverter().apply(e);
}
}
示例5: onNext
import io.reactivex.functions.Action; //導入方法依賴的package包/類
private void onNext(Action doNotify)
{
boolean applyingUpdate = _isApplyingUpdate.get();
_isApplyingUpdate.set(true);
if (!applyingUpdate) {
long ticket = _nextTicket.getAndIncrement();
// ensure ordered
while (_nowServing.get() != ticket) {
Thread.yield();
}
}
try {
doNotify.run();
}
catch (Exception e) {
throw new RuntimeException(e);
}
if (!applyingUpdate) {
// allow the next update to take hold
_nowServing.incrementAndGet();
_isApplyingUpdate.set(false);
}
}
示例6: emitUpdate
import io.reactivex.functions.Action; //導入方法依賴的package包/類
private void emitUpdate(K key, Consumer<Processor<V, V>> updater, Action missHandler, boolean disconnect)
{
Processor<V, V> subject = null;
if (disconnect) {
_writeLock.lock();
}
else {
_readLock.lock();
}
try {
// if we have a subject, we will emit the new value on the subject
if (_weakSources.containsKey(key)) {
WeakReference<Processor<V, V>> weakSource = _weakSources.get(key);
subject = weakSource.get();
}
if (disconnect) {
_weakSources.remove(key);
_weakCache.remove(key);
_cache.remove(key);
}
}
finally {
if (disconnect) {
_writeLock.unlock();
}
else {
_readLock.unlock();
}
}
try {
if (subject != null) {
updater.accept(subject);
}
else {
missHandler.run();
}
}
catch (Exception e) {
throw new RuntimeException(e);
}
}