将Stream <Item>转换为Stream <List <Item >>

沙顿

我尝试按流获取文件夹中的所有文件。

Directort(path).list()返回Stream<FileSystemEntity>

我要退货Stream<List<FileSystemEntity>>

例:

1 => 1
2 => 1,2
3 => 1,2,3
Petrus Nguyen Thai Hoc

scan从运营商rxdart是最好的答案
https://pub.dev/documentation/rxdart/latest/rx/ScanExtension/scan.html https://rxjs.dev/api/operators/scan

Stream<FileSystemEntity> source$ = ...;

Stream<List<FileSystemEntity>> result$ = source$.scan(
    (acc, element, _) => [...acc, element],
    [],
);

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

将Single <List <Item >>转换为Observable <Item>?

将List <Item>转换为json

将Flowables <Item>转换为Flowable <List <Item >>或其他可观察到的

将List <List <String >>转换为Stream <Stream <String >>

如何将Stream [IO,List [A]]转换为Stream [IO,A]

Flutter for Web,如何将List <dynamic>转换为List <Item>?

如何将Stream <QuerySnapshot>转换为List <myObject>

将 Stream<QuerySnapshot<Map<String, dynamic>>> 转换为 List?

使用 flatMapToInt() 方法将 Stream<List<Integer>> 转换为 IntStream

如何在 dart/Flutter 中将 List<Item> 转换为 Map<Datetime, List<Item>>

Sitecore内容搜索,转换为List <item>并进行编辑

如何对Box <dyn Stream <Item =()>>使用映射?

如何将 Vec<Item> 转换为 Vec<String>?

使用数组元素将 javascript 对象转换为 xml 为 <item><item>

无法将类型“ item here”的对象转换为类型“ item here”

如何在Java 8中使用Stream将List <FirstObject []>转换为List <SecondObject>?

Flutter-Firestore 将 Stream<List<DocumentSnapshot<Map<String, dynamic>>>> 转换为 List<MyClass>

在flutter中将Stream <List <String >>转换为List <String>

将Stream转换为IntStream

将 FormFile 转换为 Stream

如何使用 Stream 将 Arraylist<Person> 转换为 Map<String, List<Long>>?

如何使用Stream将MultiValueMap <String,String>转换为Map <String,List <Long >>?

如何使用Stream将MultiValueMap <String,String>转换为Map <String,List <Long >>?

如何将List [IO [Unit]]转换为Stream [IO,Unit]

Java8:如何使用Stream将Map <X,List <Y >>转换为Map <Y,X>?

将Stream <Stream <T >>转换为Stream <T>

如何在 F# 中将项目列表转换为 List<Item>

我需要从XML List-Item转换为Indesign xml代码

Stream.of(item).collect(Collectors.toSomeCollection())是否比新的SomeCollection(Arrays.asList(item))快?