https://github.com/5310/callbag-latest-batch
A Callbag operator that converts a listenable source into a pullable one by batching data between requests.
https://github.com/5310/callbag-latest-batch
Last synced: 2 months ago
JSON representation
A Callbag operator that converts a listenable source into a pullable one by batching data between requests.
- Host: GitHub
- URL: https://github.com/5310/callbag-latest-batch
- Owner: 5310
- Created: 2019-02-12T13:12:58.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-04-04T04:56:20.000Z (about 3 years ago)
- Last Synced: 2025-01-20T06:38:14.305Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
callbag-latest-batch
--------------------[Callbag](https://github.com/callbag/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](https://github.com/krawaller/callbag-latest) but one that collects all the interim data.
[](https://badge.fury.io/js/callbag-latest-batch)
[](https://travis-ci.org/5310/callbag-latest-batch)## example
```js
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))
)
```