JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://rawgit.com/baconjs/bacon.js/master/dist/Bacon.js"></script>
<button id="flush">Flush</button>
<div id="log"></div>
CSS
#log {
white-space: pre;
}
JavaScript
$('#flush').on('click', function (e) {
var stream = new Bacon.Bus();
stream
.bufferWithCount(2)
.bufferingThrottle(1000)
.flatMap(batch => {
batch = batch.map(x => x*2); //this should be an async op
return Bacon.fromArray(batch);
})
.fold([], (arr, val) => { return arr.concat(val) })
// .bufferWithTime(1000)//one thang per interval
.onValue(val => $('#log').append(val+"\n"));
for (var i=0; i<10; i++) {
stream.push(i);
}
stream.end()
});