本文介绍了如何将多个Streams合并成一个更高级别的Stream?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个流, c> package c:package:async $> c $ c>将两个流组合成一个流对,然后从中创建 C 对象。
importpackage:asyncshow StreamZip;
...
Stream< C> createCs(Stream A as,Stream B bs)=>
new StreamZip([as,bs])map((ab)=> new C(ab [0],ab [1]
I have two streams, Stream<A> and Stream<B>. I have a constructor for a type C that takes an A and a B. How do I merge the two Streams into a Stream<C>?
解决方案
You can use StreamZip in package:async to combine two streams into one stream of pairs, then create the C objects from that.
import "package:async" show StreamZip; ... Stream<C> createCs(Stream<A> as, Stream<B> bs) => new StreamZip([as, bs]).map((ab) => new C(ab[0], ab[1]));
这篇关于如何将多个Streams合并成一个更高级别的Stream?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!