callbag-latest-batch
v1.0.1
Published
A Callbag operator that converts a listenable source into a pullable one by batching data between requests.
Downloads
5
Maintainers
Readme
callbag-latest-batch
Callbag operator that turns a listenable source into a pullable source, emiting all the data since the last request batched within an array, if any.
Much like callbag-latest but one that collects all the interim data.
example
const interval = require('callbag-interval')
const sample = require('callbag-sample')
const pipe = require('callbag-pipe')
const latestBatch = require('callbag-latest-batch')
const randomStream = pipe( // random numbers generated every second
interval(1000),
map(() => Math.floor(Math.random()*100))
)
const submitActionStream = pipe( // collected into arrays every five seconds
interval(5000),
sample(latestBatch(randomStream))
)