目录

any(条件操作符)

any图解

any测试用例

any测试用例说明

any实用场景


any(条件操作符

Single<Boolean> any(Predicate<? super T> predicate)

如果源Publisher发出的任何项满足指定条件,则返回发出true的Single,否则返回false。

any图解

RxJava2 Flowable 条件操作符 any

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

any测试用例说明

any操作符对Publisher发射的项目进行一一判断,只要有满足条件的的项目就返回true,都不满足则返回false

 

any实用场景

(后面完善)

相关文章:

  • 2021-09-07
  • 2021-12-03
  • 2021-06-15
  • 2021-05-28
  • 2022-12-23
  • 2021-04-04
  • 2021-12-30
  • 2021-12-02
猜你喜欢
  • 2021-08-27
  • 2021-06-02
  • 2021-06-26
  • 2021-08-17
  • 2022-01-16
  • 2021-12-16
  • 2021-04-07
相关资源
相似解决方案