• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Function3类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.reactivex.functions.Function3的典型用法代码示例。如果您正苦于以下问题:Java Function3类的具体用法?Java Function3怎么用?Java Function3使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Function3类属于io.reactivex.functions包,在下文中一共展示了Function3类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: combineLatestShouldTakeTheLastEventsOfASetOfObservablesAndCombinesThem

import io.reactivex.functions.Function3; //导入依赖的package包/类
/**
 * In this experiment, we will use RxJava to pick a lock. Our lock has three
 * tumblers. We will need them all to be up to unlock the lock!
 */

@Test
public void combineLatestShouldTakeTheLastEventsOfASetOfObservablesAndCombinesThem() {

	Observable<Boolean> tumbler1Observable = Observable.just(20).map(integer -> new Random().nextInt(integer) > 15)
			.delay(new Random().nextInt(20), TimeUnit.MILLISECONDS).repeat(1000);
	Observable<Boolean> tumbler2Observable = Observable.just(20).map(integer -> new Random().nextInt(integer) > 15)
			.delay(new Random().nextInt(20), TimeUnit.MILLISECONDS).repeat(1000);
	Observable<Boolean> tumbler3Observable = Observable.just(20).map(integer -> new Random().nextInt(integer) > 15)
			.delay(new Random().nextInt(20), TimeUnit.MILLISECONDS).repeat(1000);

	Function3<Boolean, Boolean, Boolean, Boolean> combineTumblerStatesFunction = (tumblerOneUp, tumblerTwoUp,
			tumblerThreeUp) -> {
		Boolean allTumblersUnlocked = tumblerOneUp && tumblerTwoUp && tumblerThreeUp;
		return allTumblersUnlocked;
	};

	Observable<Boolean> lockIsPickedObservable = Observable
			.combineLatest(tumbler1Observable, tumbler2Observable, tumbler3Observable, combineTumblerStatesFunction)
			.takeUntil(unlocked -> unlocked == true);
	lockIsPickedObservable.subscribe(testObservable);
	testObservable.awaitTerminalEvent();
	List<Object> onNextEvents = testObservable.values();
	assertThat(onNextEvents.get(onNextEvents.size()-1)).isEqualTo(null);
}
 
开发者ID:vogellacompany,项目名称:code-examples-android-expert,代码行数:30,代码来源:lessonC_BooleanLogicAndErrorHandling.java


示例2: FlowableStateMachine

import io.reactivex.functions.Function3; //导入依赖的package包/类
public FlowableStateMachine(Flowable<In> source, //
        Callable<? extends State> initialState, //
        Function3<? super State, ? super In, ? super Emitter<Out>, ? extends State> transition, //
        BiConsumer<? super State, ? super Emitter<Out>> completionAction, //
        Consumer3<? super State, ? super Throwable, ? super Emitter<Out>> errorAction, //
        BackpressureStrategy backpressureStrategy, //
        int requestBatchSize) {
    Preconditions.checkNotNull(initialState);
    Preconditions.checkNotNull(transition);
    Preconditions.checkNotNull(backpressureStrategy);
    Preconditions.checkArgument(requestBatchSize > 0,
            "initialRequest must be greater than zero");
    this.source = source;
    this.initialState = initialState;
    this.transition = transition;
    this.completionAction = completionAction;
    this.errorAction = errorAction;
    this.backpressureStrategy = backpressureStrategy;
    this.requestBatchSize = requestBatchSize;
}
 
开发者ID:davidmoten,项目名称:rxjava2-extras,代码行数:21,代码来源:FlowableStateMachine.java


示例3: StateMachineSubscriber

import io.reactivex.functions.Function3; //导入依赖的package包/类
StateMachineSubscriber( //
        Callable<? extends State> initialState,
        Function3<? super State, ? super In, ? super Emitter<Out>, ? extends State> transition, //
        BiConsumer<? super State, ? super Emitter<Out>> completionAction, //
        Consumer3<? super State, ? super Throwable, ? super Emitter<Out>> errorAction, //
        BackpressureStrategy backpressureStrategy, //
        int requestBatchSize, //
        Subscriber<? super Out> child) {
    this.initialState = initialState;
    this.transition = transition;
    this.completionAction = completionAction;
    this.errorAction = errorAction;
    this.backpressureStrategy = backpressureStrategy;
    this.requestBatchSize = requestBatchSize;
    this.child = child;
    this.count = requestBatchSize;
}
 
开发者ID:davidmoten,项目名称:rxjava2-extras,代码行数:18,代码来源:FlowableStateMachine.java


示例4: toCommentDetail

import io.reactivex.functions.Function3; //导入依赖的package包/类
public static <T> Single<DetailBean<T>> toCommentDetail(Single<T> detailSingle,
                                            Single<List<CommentBean>> bestCommentsSingle,
                                            Single<List<CommentBean>> commentsSingle){
    return Single.zip(detailSingle, bestCommentsSingle, commentsSingle,
            new Function3<T, List<CommentBean>, List<CommentBean>, DetailBean<T>>() {
                @Override
                public DetailBean<T> apply(T t, List<CommentBean> commentBeen,
                                           List<CommentBean> commentBeen2) throws Exception {
                    return new DetailBean<T>(t,commentBeen,commentBeen2);
                }
            });
}
 
开发者ID:newbiechen1024,项目名称:NovelReader,代码行数:13,代码来源:RxUtils.java


示例5: TransformerStateMachine

import io.reactivex.functions.Function3; //导入依赖的package包/类
private TransformerStateMachine(Callable<? extends State> initialState,
        Function3<? super State, ? super In, ? super FlowableEmitter<Out>, ? extends State> transition,
        BiPredicate<? super State, ? super FlowableEmitter<Out>> completion,
        BackpressureStrategy backpressureStrategy, int requestBatchSize) {
    Preconditions.checkNotNull(initialState);
    Preconditions.checkNotNull(transition);
    Preconditions.checkNotNull(completion);
    Preconditions.checkNotNull(backpressureStrategy);
    Preconditions.checkArgument(requestBatchSize > 0, "initialRequest must be greater than zero");
    this.initialState = initialState;
    this.transition = transition;
    this.completion = completion;
    this.backpressureStrategy = backpressureStrategy;
    this.requestBatchSize = requestBatchSize;
}
 
开发者ID:davidmoten,项目名称:rxjava2-extras,代码行数:16,代码来源:TransformerStateMachine.java


示例6: create

import io.reactivex.functions.Function3; //导入依赖的package包/类
public static <State, In, Out> FlowableTransformer<In, Out> create(Callable<? extends State> initialState,
        Function3<? super State, ? super In, ? super FlowableEmitter<Out>, ? extends State> transition,
        BiPredicate<? super State, ? super FlowableEmitter<Out>> completion,
        BackpressureStrategy backpressureStrategy, int requestBatchSize) {
    return new TransformerStateMachine<State, In, Out>(initialState, transition, completion, backpressureStrategy,
            requestBatchSize);
}
 
开发者ID:davidmoten,项目名称:rxjava2-extras,代码行数:8,代码来源:TransformerStateMachine.java


示例7: execute

import io.reactivex.functions.Function3; //导入依赖的package包/类
private static <State, Out, In> Function<Notification<In>, Flowable<Notification<Out>>> execute(
        final Function3<? super State, ? super In, ? super FlowableEmitter<Out>, ? extends State> transition,
        final BiPredicate<? super State, ? super FlowableEmitter<Out>> completion, final Mutable<State> state,
        final BackpressureStrategy backpressureStrategy) {

    return new Function<Notification<In>, Flowable<Notification<Out>>>() {

        @Override
        public Flowable<Notification<Out>> apply(final Notification<In> in) {

            return Flowable.create(new FlowableOnSubscribe<Notification<Out>>() {

                @Override
                public void subscribe(FlowableEmitter<Notification<Out>> emitter) throws Exception {
                    FlowableEmitter<Out> w = wrap(emitter);
                    if (in.isOnNext()) {
                        state.value = transition.apply(state.value, in.getValue(), w);
                        if (!emitter.isCancelled())
                            emitter.onComplete();
                        else {
                            // this is a special emission to indicate that
                            // the transition called unsubscribe. It will be
                            // filtered later.
                            emitter.onNext(UnsubscribedNotificationHolder.<Out>unsubscribedNotification());
                        }
                    } else if (in.isOnComplete()) {
                        if (completion.test(state.value, w) && !emitter.isCancelled()) {
                            w.onComplete();
                        }
                    } else if (!emitter.isCancelled()) {
                        w.onError(in.getError());
                    }
                }

            }, backpressureStrategy);
        }
    };
}
 
开发者ID:davidmoten,项目名称:rxjava2-extras,代码行数:39,代码来源:TransformerStateMachine.java


示例8: stateMachine

import io.reactivex.functions.Function3; //导入依赖的package包/类
public static <State, In, Out> FlowableTransformer<In, Out> stateMachine(Callable<? extends State> initialState,
        Function3<? super State, ? super In, ? super FlowableEmitter<Out>, ? extends State> transition,
        BiPredicate<? super State, ? super FlowableEmitter<Out>> completion,
        BackpressureStrategy backpressureStrategy, int requestBatchSize) {
    return TransformerStateMachine.create(initialState, transition, completion, backpressureStrategy,
            requestBatchSize);
}
 
开发者ID:davidmoten,项目名称:rxjava2-extras,代码行数:8,代码来源:Transformers.java


示例9: LambdaChannelResponder

import io.reactivex.functions.Function3; //导入依赖的package包/类
public LambdaChannelResponder(
        ChannelSubscriber<Request, Response> actual,
        State initialState,
        Function3<State, Request, ChannelTerminalEvents, ? extends Publisher<Response>> queryMapper,
                Consumer<? super State> stateConsumer) {
    this.state = initialState;
    this.actual = actual;
    this.queryMapper = queryMapper;
    this.stateConsumer = stateConsumer;
    this.cancelled = PublishSubject.create().toSerialized();
}
 
开发者ID:akarnokd,项目名称:ReactiveChannel,代码行数:12,代码来源:LambdaChannelResponder.java


示例10: onZipRequest

import io.reactivex.functions.Function3; //导入依赖的package包/类
public void onZipRequest(View view) {
    //使用zip操作符合并等待多个网络请求完成后,再刷新界面
    //例如下面:数据来自3个不同的接口
    Observable<ResultBean> mobileObservable = EasyHttp.get("http://apis.juhe.cn/mobile/get")
            .params("phone", "18688994275")
            .params("dtype", "json")
            .params("key", "5682c1f44a7f486e40f9720d6c97ffe4")
            .execute(new CallClazzProxy<TestApiResult1<ResultBean>, ResultBean>(ResultBean.class) {
            });

    Observable<Content> searchObservable = EasyHttp.get("/ajax.php")
            .baseUrl("http://fy.iciba.com")
            .params("a", "fy")
            .params("f", "auto")
            .params("t", "auto")
            .params("w", "hello world")
            //采用代理
            .execute(new CallClazzProxy<TestApiResult6<Content>, Content>(Content.class) {
            });

    Observable<List<SectionItem>> listObservable = EasyHttp.get("http://news-at.zhihu.com/api/3/sections")
            .execute(new CallClazzProxy<TestApiResult5<List<SectionItem>>, List<SectionItem>>(new TypeToken<List<SectionItem>>() {
            }.getType()) {
            });
    //new Function3最后一个参数这里用的是List<Object>,表示将3个返回的结果,放在同一个集合最终一次性返回,你也可以指定返回其它你需要的数据类型并不一定是List<Object>
    //假如这三个接口返回的都是TestBean,那么就可以直接用具体的List<TestBean>,不需要用List<Object>
    Observable.zip(mobileObservable, searchObservable, listObservable, new Function3<ResultBean, Content, List<SectionItem>, List<Object>>() {
        @Override
        public List<Object> apply(@NonNull ResultBean resultbean, @NonNull Content content, @NonNull List<SectionItem> sectionItems) throws Exception {
            //将接收到的3个数据先暂存起来,一次性发给订阅者
            List list = new ArrayList();
            list.add(resultbean);
            list.add(content);
            list.add(sectionItems);
            return list;
        }
    }).subscribe(new BaseSubscriber<List<Object>>() {
        @Override
        public void onError(ApiException e) {
            showToast(e.getMessage());
        }

        @Override
        public void onNext(@NonNull List<Object> objects) {
            showToast(objects.toString());
        }
    });
}
 
开发者ID:zhou-you,项目名称:RxEasyHttp,代码行数:49,代码来源:SceneActivity.java


示例11: then

import io.reactivex.functions.Function3; //导入依赖的package包/类
/**
 * Matches when all observable sequences have an available
 * element and projects the elements by invoking the selector function.
 *
 * @param <R> the result type
 * @param selector
 *            the function that will be invoked for elements in the source sequences.
 * @return the plan for the matching
 * @throws NullPointerException
 *             if selector is null
 */
public <R> Plan<R> then(Function3<T1, T2, T3, R> selector) {
    if (selector == null) {
        throw new NullPointerException();
    }
    return new Plan3<T1, T2, T3, R>(this, selector);
}
 
开发者ID:akarnokd,项目名称:RxJava2Extensions,代码行数:18,代码来源:Pattern3.java


示例12: indexedMap

import io.reactivex.functions.Function3; //导入依赖的package包/类
/**
 * Transforms the list using the supplied map. The map will receive a Flowable
 * bound to the previous and next items in the list. The previous and next Flowables will emit
 * when the item moves within the list or when items surrounding the list are moved.
 * @param transform A function transforming the source to the target type
 * @param <R> The type of the mapped value
 * @return A new FlowableList which has values mapped via the supplied map
 */
public <R> FlowableList<R> indexedMap(final Function3<T, Flowable<Optional<T>>, Flowable<Optional<T>>, R> transform)
{
    return new IndexedFlowableList<>(this, transform);
}
 
开发者ID:mproberts,项目名称:rxtools,代码行数:13,代码来源:FlowableList.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Property类代码示例发布时间:2022-05-23
下一篇:
Java Marker类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap