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

Java Functions类代码示例

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

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



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

示例1: onScheduleCrashes

import io.reactivex.internal.functions.Functions; //导入依赖的package包/类
@Test
public void onScheduleCrashes() {
    RxSwingPlugins.setOnSchedule(new Function<Runnable, Runnable>() {
        @Override
        public Runnable apply(Runnable r) throws Exception {
            throw new IllegalStateException("Failure");
        }
    });

    try {
        RxSwingPlugins.onSchedule(Functions.EMPTY_RUNNABLE);
        Assert.fail("Should have thrown!");
    } catch (IllegalStateException ex) {
        Assert.assertEquals("Failure", ex.getMessage());
    }

    RxSwingPlugins.reset();

    Assert.assertSame(Functions.EMPTY_RUNNABLE, RxSwingPlugins.onSchedule(Functions.EMPTY_RUNNABLE));
}
 
开发者ID:akarnokd,项目名称:RxJava2Swing,代码行数:21,代码来源:RxSwingPluginsTest.java


示例2: runOk

import io.reactivex.internal.functions.Functions; //导入依赖的package包/类
protected void runOk(){
    /*
    - empty
        - 直接调用complete
     */
    task = Flowable.empty()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Consumer<Object>() {
                @Override
                public void accept(Object s) throws Exception {
                    notifyy("item--" + s);
                }
            }, Functions.ERROR_CONSUMER,
                    new Action() {
                        @Override
                        public void run() throws Exception {
                            notifyy("onComplete---结束了!@@");
                        }
                    },
                    FlowableInternalHelper.RequestMax.INSTANCE);

}
 
开发者ID:cowthan,项目名称:AyoRxJava,代码行数:24,代码来源:Rx_empty.java


示例3: runOk

import io.reactivex.internal.functions.Functions; //导入依赖的package包/类
protected void runOk(){
    final String[] list1 = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"};
    final String[] list2 = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"};

    Flowable<String> flowable1 = Flowable.fromArray(list1);
    Flowable<String> flowable2 = Flowable.fromArray(list2);
    task = Flowable.merge(flowable1, flowable2)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Consumer<Object>() {
                @Override
                public void accept(Object s) throws Exception {
                    notifyy("item--" + s);
                }
            }, Functions.ERROR_CONSUMER,
                    new Action() {
                        @Override
                        public void run() throws Exception {
                            notifyy("onComplete---结束了!@@");
                        }
                    },
                    FlowableInternalHelper.RequestMax.INSTANCE);

}
 
开发者ID:cowthan,项目名称:AyoRxJava,代码行数:25,代码来源:Rx_merge2.java


示例4: runOk

import io.reactivex.internal.functions.Functions; //导入依赖的package包/类
protected void runOk(){
    /*
    - empty
        - 直接调用complete
     */
    task = Flowable.just(1, "a", 2, "b")
            .ofType(String.class)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Consumer<Object>() {
                @Override
                public void accept(Object s) throws Exception {
                    notifyy(s.toString());
                }
            }, Functions.ERROR_CONSUMER,
                    new Action() {
                        @Override
                        public void run() throws Exception {
                            notifyy("onComplete---结束了!@@");
                        }
                    },
                    FlowableInternalHelper.RequestMax.INSTANCE);

}
 
开发者ID:cowthan,项目名称:AyoRxJava,代码行数:25,代码来源:Rx_ofType.java


示例5: runOk

import io.reactivex.internal.functions.Functions; //导入依赖的package包/类
protected void runOk(){
    /*
    - timer
        - 用于一次性的延时任务
        - 如Flowable.timer(600, TimeUnit.MILLISECONDS)表示600毫秒后激活onNext
        - 然后还会激活onComplete
        - 具体发的item是什么值,好像只能是0
     */
    task = Flowable.timer(600, TimeUnit.MILLISECONDS)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Consumer<Long>() {
                @Override
                public void accept(Long s) throws Exception {
                    notifyy("item--" + s);
                }
            }, Functions.ERROR_CONSUMER,
                    new Action() {
                        @Override
                        public void run() throws Exception {
                            Log.i("repeat", "on complete");
                        }
                    },
                    FlowableInternalHelper.RequestMax.INSTANCE);

}
 
开发者ID:cowthan,项目名称:AyoRxJava,代码行数:27,代码来源:Rx_timer.java


示例6: runOk

import io.reactivex.internal.functions.Functions; //导入依赖的package包/类
protected void runOk(){
    /*
    - empty
        - 直接调用complete
     */
    task = Flowable.interval(1, 1, TimeUnit.SECONDS)
            .take(4)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Consumer<Long>() {
                @Override
                public void accept(Long s) throws Exception {
                    notifyy(s + "");
                }
            }, Functions.ERROR_CONSUMER,
                    new Action() {
                        @Override
                        public void run() throws Exception {
                            notifyy("onComplete---结束了!@@");
                        }
                    },
                    FlowableInternalHelper.RequestMax.INSTANCE);

}
 
开发者ID:cowthan,项目名称:AyoRxJava,代码行数:25,代码来源:Rx_take.java


示例7: runOk

import io.reactivex.internal.functions.Functions; //导入依赖的package包/类
protected void runOk(){
    /*
    - never
        - 什么也不会发,什么也不会调用
     */
    task = Flowable.never()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Consumer<Object>() {
                @Override
                public void accept(Object s) throws Exception {
                    notifyy("item--" + s);
                }
            }, Functions.ERROR_CONSUMER,
                    new Action() {
                        @Override
                        public void run() throws Exception {
                            notifyy("onComplete---结束了!@@");
                        }
                    },
                    FlowableInternalHelper.RequestMax.INSTANCE);

}
 
开发者ID:cowthan,项目名称:AyoRxJava,代码行数:24,代码来源:Rx_never.java


示例8: runOk

import io.reactivex.internal.functions.Functions; //导入依赖的package包/类
protected void runOk(){
    /*
    - empty
        - 直接调用complete
     */
    Flowable.interval(0, 1, TimeUnit.SECONDS)
            .sample(400, TimeUnit.MILLISECONDS)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Consumer<Long>() {
                           @Override
                           public void accept(Long s) throws Exception {
                               notifyy(s + "");
                           }
                       }, Functions.ERROR_CONSUMER,
                    new Action() {
                        @Override
                        public void run() throws Exception {
                            notifyy("onComplete---结束了!@@");
                        }
                    },
                    FlowableInternalHelper.RequestMax.INSTANCE);

}
 
开发者ID:cowthan,项目名称:AyoRxJava,代码行数:25,代码来源:Rx_sample.java


示例9: runOk

import io.reactivex.internal.functions.Functions; //导入依赖的package包/类
protected void runOk(){
    /*
    - empty
        - 直接调用complete
     */
    task = Flowable.interval(1, 1, TimeUnit.SECONDS)
            .take(10)
            .takeLast(4, TimeUnit.SECONDS)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Consumer<Long>() {
                @Override
                public void accept(Long s) throws Exception {
                    notifyy(s + "");
                }
            }, Functions.ERROR_CONSUMER,
                    new Action() {
                        @Override
                        public void run() throws Exception {
                            notifyy("onComplete---结束了!@@");
                        }
                    },
                    FlowableInternalHelper.RequestMax.INSTANCE);

}
 
开发者ID:cowthan,项目名称:AyoRxJava,代码行数:26,代码来源:Rx_takeLast2.java


示例10: runOk

import io.reactivex.internal.functions.Functions; //导入依赖的package包/类
protected void runOk(){
    Flowable.interval(0, 1, TimeUnit.SECONDS)
            .throttleFirst(3000, TimeUnit.MILLISECONDS)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Consumer<Long>() {
                           @Override
                           public void accept(Long s) throws Exception {
                               notifyy(s + "");
                           }
                       }, Functions.ERROR_CONSUMER,
                    new Action() {
                        @Override
                        public void run() throws Exception {
                            notifyy("onComplete---结束了!@@");
                        }
                    },
                    FlowableInternalHelper.RequestMax.INSTANCE);

}
 
开发者ID:cowthan,项目名称:AyoRxJava,代码行数:21,代码来源:Rx_throttleFirst.java


示例11: runOk

import io.reactivex.internal.functions.Functions; //导入依赖的package包/类
protected void runOk(){
    /*
    - empty
        - 直接调用complete
     */
    task = Flowable.interval(1, 1, TimeUnit.SECONDS)
            .skip(4, TimeUnit.SECONDS)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Consumer<Long>() {
                @Override
                public void accept(Long s) throws Exception {
                    notifyy(s + "");
                }
            }, Functions.ERROR_CONSUMER,
                    new Action() {
                        @Override
                        public void run() throws Exception {
                            notifyy("onComplete---结束了!@@");
                        }
                    },
                    FlowableInternalHelper.RequestMax.INSTANCE);

}
 
开发者ID:cowthan,项目名称:AyoRxJava,代码行数:25,代码来源:Rx_skip2.java


示例12: usingDisposerThrows5

import io.reactivex.internal.functions.Functions; //导入依赖的package包/类
@Test
public void usingDisposerThrows5() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        Nono.using(Functions.justCallable(0),
                new Function<Integer, Nono>() {
                    @Override
                    public Nono apply(Integer v) throws Exception {
                        throw new IOException();
                    }
                },
                new Consumer<Integer>() {
                    @Override
                    public void accept(Integer t) throws Exception {
                        throw new IllegalArgumentException();
                    }
                }, false
        )
        .test()
        .assertFailure(IOException.class);

        TestHelper.assertError(errors, 0, IllegalArgumentException.class);
    } finally {
        RxJavaPlugins.reset();
    }
}
 
开发者ID:akarnokd,项目名称:RxJava2Extensions,代码行数:27,代码来源:NonoTest.java


示例13: mapOptionalSyncFusedConditional

import io.reactivex.internal.functions.Functions; //导入依赖的package包/类
@Test
public void mapOptionalSyncFusedConditional() {
    TestObserver<Integer> ts = TestHelper.fusedObserver(QueueSubscription.ANY);

    Observable.range(1, 5)
    .compose(ObservableInterop.mapOptional(v -> {
        if (v % 2 == 0) {
            return Optional.of(-v);
        }
        return Optional.empty();
    }))
    .filter(Functions.alwaysTrue())
    .subscribeWith(ts)
    .assertOf(TestHelper.assertFusedObserver(QueueSubscription.SYNC))
    .assertResult(-2, -4);
}
 
开发者ID:akarnokd,项目名称:RxJava2Jdk8Interop,代码行数:17,代码来源:ObservableInteropTest.java


示例14: fusedThrowsInPostEmissionCheckErrorDelayed

import io.reactivex.internal.functions.Functions; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void fusedThrowsInPostEmissionCheckErrorDelayed() {
    Flowables.orderedMerge(Functions.<Integer>naturalComparator(),
            true,
            Flowable.just(1).map(new Function<Integer, Integer>() {
                @Override
                public Integer apply(Integer v) throws Exception {
                    throw new IllegalArgumentException();
                }
            }),
            Flowable.just(2, 3))
    .test(0L)
    .requestMore(2)
    .assertFailure(IllegalArgumentException.class, 2, 3);
}
 
开发者ID:akarnokd,项目名称:RxJava2Extensions,代码行数:17,代码来源:FlowableOrderedMergeTest.java


示例15: bothError

import io.reactivex.internal.functions.Functions; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void bothError() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        Flowables.orderedMerge(Functions.<Integer>naturalComparator(),
                Flowable.<Integer>error(new IOException("first")),
                Flowable.<Integer>error(new IOException("second"))
        )
        .test()
        .assertFailureAndMessage(IOException.class, "first");

        TestHelper.assertUndeliverable(errors, 0, IOException.class, "second");
    } finally {
        RxJavaPlugins.reset();
    }
}
 
开发者ID:akarnokd,项目名称:RxJava2Extensions,代码行数:18,代码来源:FlowableOrderedMergeTest.java


示例16: consumerCompleteFused

import io.reactivex.internal.functions.Functions; //导入依赖的package包/类
@Test
public void consumerCompleteFused() {
    TestSubscriber<Integer> ts = TestHelper.fusedSubscriber(QueueSubscription.ANY);

    Flowable.range(1, 5)
    .compose(FlowableTransformers.mapFilter(new BiConsumer<Integer, BasicEmitter<Integer>>() {
        @Override
        public void accept(Integer t, BasicEmitter<Integer> e) throws Exception {
            e.doComplete();
        }
    }))
    .filter(Functions.alwaysTrue())
    .subscribe(ts);

    ts.assertOf(TestHelper.<Integer>assertFusedSubscriber(QueueSubscription.SYNC))
    .assertResult();
}
 
开发者ID:akarnokd,项目名称:RxJava2Extensions,代码行数:18,代码来源:FlowableMapFilterConditionalTest.java


示例17: innerDoubleError

import io.reactivex.internal.functions.Functions; //导入依赖的package包/类
@Test
public void innerDoubleError() {
    List<Throwable> error = TestHelper.trackPluginErrors();
    try {
        Flowable.just(1)
        .compose(FlowableTransformers.switchFlatMap(Functions.justFunction(new Flowable<Integer>() {
            @Override
            protected void subscribeActual(Subscriber<? super Integer> s) {
                s.onSubscribe(new BooleanSubscription());
                s.onError(new IOException());
                s.onError(new IllegalArgumentException());
            }
        }), 2))
        .test()
        .assertFailure(IOException.class);

        TestHelper.assertError(error, 0, IllegalArgumentException.class);
    } finally {
        RxJavaPlugins.reset();
    }
}
 
开发者ID:akarnokd,项目名称:RxJava2Extensions,代码行数:22,代码来源:FlowableSwitchFlatMapTest.java


示例18: nonEmptyBothErrorDelayed

import io.reactivex.internal.functions.Functions; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void nonEmptyBothErrorDelayed() {
    Flowables.orderedMerge(Functions.<Integer>naturalComparator(),
            true,
            Flowable.just(1).concatWith(Flowable.<Integer>error(new IOException("first"))),
            Flowable.just(2).concatWith(Flowable.<Integer>error(new IOException("second")))
    )
    .test()
    .assertFailure(CompositeException.class, 1, 2)
    .assertOf(new Consumer<TestSubscriber<Integer>>() {
        @Override
        public void accept(TestSubscriber<Integer> ts) throws Exception {
            List<Throwable> list = TestHelper.compositeList(ts.errors().get(0));

            TestHelper.assertError(list, 0, IOException.class, "first");
            TestHelper.assertError(list, 1, IOException.class, "second");
        }
    });
}
 
开发者ID:akarnokd,项目名称:RxJava2Extensions,代码行数:21,代码来源:FlowableOrderedMergeTest.java


示例19: usingDisposerThrows2

import io.reactivex.internal.functions.Functions; //导入依赖的package包/类
@Test
public void usingDisposerThrows2() {
    Nono.using(Functions.justCallable(0),
            Functions.justFunction(ioError),
            new Consumer<Integer>() {
                @Override
                public void accept(Integer t) throws Exception {
                    throw new IllegalArgumentException();
                }
            }
    )
    .test()
    .assertFailure(CompositeException.class)
    .assertOf(new Consumer<TestSubscriber<Void>>() {
        @SuppressWarnings("unchecked")
        @Override
        public void accept(TestSubscriber<Void> ts) throws Exception {
            TestHelper.assertCompositeExceptions(ts, IOException.class, IllegalArgumentException.class);
        }
    });
}
 
开发者ID:akarnokd,项目名称:RxJava2Extensions,代码行数:22,代码来源:NonoTest.java


示例20: consumerCompleteCancel

import io.reactivex.internal.functions.Functions; //导入依赖的package包/类
@Test
public void consumerCompleteCancel() {
    BehaviorProcessor<Integer> pp = BehaviorProcessor.createDefault(1);

    pp
    .compose(FlowableTransformers.mapFilter(new BiConsumer<Integer, BasicEmitter<Integer>>() {
        @Override
        public void accept(Integer t, BasicEmitter<Integer> e) throws Exception {
            e.doComplete();
        }
    }))
    .filter(Functions.alwaysTrue())
    .test()
    .assertResult();

    assertFalse(pp.hasSubscribers());
}
 
开发者ID:akarnokd,项目名称:RxJava2Extensions,代码行数:18,代码来源:FlowableMapFilterConditionalTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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