简体   繁体   English

Dart:流依赖于其他流

[英]Dart: Stream depends on other stream

I have a stream Stream<List<String>> aStream , it contains references.我有一个流Stream<List<String>> aStream ,它包含引用。 I want a stream Stream<List<T>> bStream that triggers when the references change and when the content of the reference changes.我想要一个流Stream<List<T>> bStream ,它在引用更改和引用内容更改时触发。

what i tried so far is: `到目前为止我尝试过的是:`

await for(List aList in aStream){
      yield* StreamGroup.merge(aList.entries.map((String reference){
        return refrencefunction(aString);
      }));
    }    

` `

Thanks for your help谢谢你的帮助

If refrencefunction returns a Stream for each reference, and you want to yield a List<T> containing all currently referenced values whenever any of the referenced values change, you'll have to manage a stream subscription for each reference, and keep a copy of the last value for each reference.如果refrencefunction为每个引用返回一个Stream ,并且您希望在任何引用值发生更改时生成一个包含所有当前引用值的List<T> ,则您必须管理每个引用的流订阅,并保留一份每个引用的最后一个值。 Which I'm afraid won't quite fit on a single line :-)恐怕这不太适合单行:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM