system.reactive - group and aggregate with rxjs -
scan works this(with sum function):
1-1-1-1-1-1 -> 1-2-3-4-5-6
but need this: n=3
1-1-1-1-1-1 -> 3-3
how achieve behavior?
in rxjs can use bufferwithcount
:
var source = rx.observable.from([1,1,1,1,1,1]) .bufferwithcount(3) .flatmap(group => rx.observable.from(group).sum());
you optionally use windowwithcount
don't have rewrap output in order use sum
you'll empty final window well, fire out extraneous 0 value.
Comments
Post a Comment