https://github.com/andarist/callbag-from-event-pattern
👜 Callbag source factory from addHandler and removeHandler pair.
https://github.com/andarist/callbag-from-event-pattern
callbag callbags
Last synced: about 2 months ago
JSON representation
👜 Callbag source factory from addHandler and removeHandler pair.
- Host: GitHub
- URL: https://github.com/andarist/callbag-from-event-pattern
- Owner: Andarist
- Created: 2018-04-26T16:41:52.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-11T20:08:20.000Z (almost 7 years ago)
- Last Synced: 2025-03-06T21:02:51.634Z (7 months ago)
- Topics: callbag, callbags
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# callbag-from-event-pattern
Callbag source factory from `addHandler` and `removeHandler` pair.
## Example
```js
import forEach from 'callbag-for-each'
import fromEventPattern from 'callbag-from-event-pattern'
import map from 'callbag-map'
import pipe from 'callbag-pipe'const addHandler = handler => {
document.addEventListener('click', handler)
}const removeHandler = handler => {
document.removeEventListener('click', handler)
}pipe(
fromEventPattern(addHandler, removeHandler),
map(({ clientX: x, clientY: y }) => ({ x, y })),
forEach(coord => {
// will log coordinate of each click
console.log(coord)
}),
)
```