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

Popular posts from this blog

python - jinja2: TemplateSyntaxError: expected token ',', got 'string' -

node.js - NodeJS remote terminal to Dropbear OpenWRT-Server -

Qt4: how to send QString inside a struct via QSharedMemory -