Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/krawaller/callbag-latest
https://github.com/krawaller/callbag-latest
Last synced: 18 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/krawaller/callbag-latest
- Owner: krawaller
- License: mit
- Created: 2018-02-14T08:23:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-23T08:22:28.000Z (over 6 years ago)
- Last Synced: 2024-09-18T06:18:41.590Z (about 2 months ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-callbags - latest
README
# callbag-latest
[Callbag](https://github.com/callbag/callbag) operator that turns a listenable source into a pullable source, that emits the latest data (if any) from the listenable upon request.
Often useful in conjunction with [callbag-sample](https://github.com/staltz/callbag-sample).
`npm install callbag-latest`
## example
```js
const fromEvent = require('callbag-from-event');
const sample = require('callbag-sample');
const pipe = require('callbag-pipe');
const map = require('callbag-map');
const latest = require('callbag-latest');const typeStream = pipe(
fromEvent(inputField, "input"),
map(e => e.target.value)
);const submitActionStream = pipe(
fromEvent(submitBtn, "click"),
sample(latest(typeStream)), // turn click events to current value of input field
map(v => ({type: "SUBMIT", value: v}))
);
```