本文整理汇总了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);
}
}