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


Java Functions类代码示例

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


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


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