c# - Reactive Extensions: Is it possible to subscribe on Sum of the result of Buffer operation? -
i trying notifications on result of aggregate functions (i.e. sum), operates on partial sequence of infinite sequence (topmost, data source sequence never completes). problem can seen here:
var seq = observable.interval(timespan.frommilliseconds(20)).buffer(10); seq.sum(l => l.sum()) .subscribe(n => s_log.debugformat("got {0}", n));
lambda l.sum() called expected (partial sums calculated), "got ..." line never printed, because subscriber never called. suspected related somehow "never ending" character of original sequence. finite sequence:
observable.range(1,100).buffer(10);
works expected. question simple: how "mark" partial fragments of infinite sequence "complete", aggregate functions work on them separately (and push results subscribers) ?
scan friend:
seq.scan(0l, (l1, l2) => l1 + l2.sum()) .subscribe(n => console.writeline("got {0}", n));
Comments
Post a Comment