需要将两个可观察物压缩在一起

时间:2019-04-17 04:40:47

标签: c# reactive-programming rx.net

我正在尝试结合两个可观察的序列。

Source1 = Observable<int>
Source2 = Observable<Observable<>>

用于引用LinqPad代码

var interval = Observable.Interval(TimeSpan.FromSeconds(0.5)).Take(20);

var interval2 = Observable.Interval(TimeSpan.FromSeconds(2)).Take(5);

var interval3 = interval.Window(interval2);

var interval4 = interval3.Select(x => x.GroupBy(y => y%2==0));

var interval6 = interval4.Select(z => z.SelectMany(h => h.GroupBy(j => j%3==0).Select(o => new {OuterKey = h.Key, InnerKey = o.Key, Seq = o.Select(b => b).ToList()})));

var interval7 = interval6.Select(x => x.SelectMany(y => y.Seq.Select(z => new {OuterKey = y.OuterKey, InnerKey = y.InnerKey,List = z})));

var interval5 = Observable.Zip(interval7,interval2,(a,b) => new {A = a, B = b});

现在,我需要使用interval2的第一个元素来压缩interval7的第一个窗口,但是interval7的结果为空。我需要这样的结果

预期结果

TRUE TRUE List 0

TRUE FALSE List 0

FALSE FALSE List 0

FALSE TRUE List 1 

实际结果

Observable 0

Observable 1

Observable 2

0 个答案:

没有答案