目录
ofType从发射的项目中过滤出指定的类型发射
1 ofType接口
<U> Flowable<U> | ofType(Class<U> clazz) Filters the items emitted by a Publisher, only emitting those of the specified type. 过滤发布者发出的项目,仅发出指定类型的项目。 |
2 ofType图解
3 ofType示例
@Test public void ofType() { System.out.println("######ofType#####"); Flowable.just(10F,20,30L,"abc").ofType(String.class).subscribe(new Consumer<String>() { @Override public void accept(String s) throws Exception { System.out.println("s = " + s); } }); }
结果
######ofType#####
s = abc
上面示例发射各种类型,过滤后仅仅允许发射String类型的数据