Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/krawaller/callbag-from-delegated-event
https://github.com/krawaller/callbag-from-delegated-event
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/krawaller/callbag-from-delegated-event
- Owner: krawaller
- License: mit
- Created: 2018-02-16T06:52:01.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-23T13:22:22.000Z (over 6 years ago)
- Last Synced: 2024-09-15T01:28:33.854Z (4 months ago)
- Language: JavaScript
- Size: 22.5 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-callbags - from-delegated-event
README
# callbag-from-delegated-event
Create a [callbag](https://github.com/callbag/callbag) listenable source from events on a DOM node. The events are filtered to those where the target element matches the given selector, or is a child of an element that matches it.
`npm install callbag-from-delegated-event`
## signature
```
(root: DOMelement, selector: string, eventName: string) => source
```## example
Create a listenable source of click events on `.pawn` elements in a surrounding game board.
```js
const fromEvent = require('callbag-from-delegated-event');
const forEach = require('callbag-for-each');const pawnClicks = fromEvent(gameBoard, '.pawn', 'click');
forEach(x => console.log(x))(pawnClicks); // MouseEvent ...
// MouseEvent ...
```