1. 程式人生 > >RxJava2 Flowable 條件操作符 any

RxJava2 Flowable 條件操作符 any

 private void doAny() {
        Flowable.just(1,2,3,4,5).any(new Predicate<Integer>() {
            @Override
            public boolean test(Integer integer) throws Exception {
                if(integer < 2) {
                    return true;
                }
                return false;
            }
        }).subscribe(new Consumer<Boolean>() {
            @Override
            public void accept(Boolean aBoolean) throws Exception {
                
            }
        });
    }


測試結果:
10-03 08:05:55.650 4425-4425/hq.demo.net I/System.out: ######doAny#####
10-03 08:05:55.670 4425-4425/hq.demo.net I/System.out: accept aBoolean = true