IObservable filteredStream = changes.Buffer(3);
但是如何引入超时TimeSpan tooLong
,以便只要两个值之间的间隔超过此最大值,计数就会从零重新启动?
答案 0 :(得分:3)
我认为这就是你所追求的目标。
var longGap = source.Throttle(tooLong);
var filtered = source
.Window(() => { return longGap; }) // Gives a window between every longGap
.Select(io => io.Buffer(maxItems).Where(l => l.Count == maxItems))
.Switch(); // Flattens the IObservable<IObservable<IList>> to IObservable<IList>