given following code use buffercount
(not quite want)...
var rx = require('rxjs/rx'); var observable = rx.observable; var subject = rx.subject; var first = new rx.subject(); var source = first.buffercount(2).map(a => a.reduce((acc,x) => acc+x,0)); var subscription = source.subscribe(console.log) first.next(1) first.next(2) first.next(2) first.next(3)
i
3 5
what i'd is
3 4 5
so buffer buffering last 2 items.
is there way simply?
have tried using buffercount
's skip
/ startbufferevery
parameter? allows generate overlapping buffers, can reduce desired. way doesn't involve emitting values have subsequently filter out. if want buffer size of 2, can use pairwise
instead of buffercount.
keith:- code using method
var rx = require('rxjs/rx'); var observable = rx.observable; var subject = rx.subject; var first = new rx.subject(); var source = first.buffercount(2,1).map(a => a.reduce((acc,x) => acc+x,0)); var subscription = source.subscribe(console.log) first.next(1) first.next(2) first.next(2) first.next(3)
Comments
Post a Comment