当前位置: 首页>>代码示例>>Java>>正文


Java Action.run方法代码示例

本文整理汇总了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();
                }
            };
        }
    };
}
 
开发者ID:PacktPublishing,项目名称:Learning-RxJava,代码行数:37,代码来源:Ch9_9.java

示例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();
                }
            };
        }
    };
}
 
开发者ID:PacktPublishing,项目名称:Learning-RxJava,代码行数:37,代码来源:Ch9_7.java

示例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;
}
 
开发者ID:carterhudson,项目名称:RxOptional,代码行数:14,代码来源:RxOptional.java

示例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);
    }
}
 
开发者ID:Ahmed-Adel-Ismail,项目名称:J-Chain,代码行数:13,代码来源:Invoker.java

示例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);
    }
}
 
开发者ID:mproberts,项目名称:rxtools,代码行数:30,代码来源:BaseFlowableList.java

示例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);
    }
}
 
开发者ID:mproberts,项目名称:rxtools,代码行数:48,代码来源:SubjectMap.java


注:本文中的io.reactivex.functions.Action.run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。