Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kt3k/event-hub
A dom which works as an event hub
https://github.com/kt3k/event-hub
Last synced: 20 days ago
JSON representation
A dom which works as an event hub
- Host: GitHub
- URL: https://github.com/kt3k/event-hub
- Owner: kt3k
- License: mit
- Created: 2015-04-23T14:38:18.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-10T11:12:52.000Z (over 7 years ago)
- Last Synced: 2024-10-04T19:20:14.067Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 219 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# event-hub v6.2.2
> event hub on a dom tree
[![CircleCI](https://circleci.com/gh/kt3k/event-hub.svg?style=svg)](https://circleci.com/gh/kt3k/event-hub)
***note*** `event-hub` depends on [classcaps](https://github.com/kt3k/classcaps).
# Usage
```html
DIV 1
DIV 2
DIV 3
```The `channel` attribute specify which events are the channel of the `.event-hub`. (If you want to set multiple channels, set them like `click mouseover` (in space-separated form)).
The `sub-click` class on the 2nd element in the `.event-hub` means that it subscribes to `click` event of the `.event-hub`.
With the above settings, all the `click` events which occur under the `.event-hub` is published to the 2nd div.
See the [DEMO](https://kt3k.github.io/event-hub/test.html).
# API
```html
```
- @class `event-hub` is the component name. You need to specify the class name in dom.
- @param {string[]} ch0, ch1,..., ch_N The channel which the event hub brokes.If the event `ch_i` bubbles up to the above `event-hub` dom, then it dispatches the event to its children which has `sub-ch_i` class in it.
## Node API
You need to call `def` of classcaps to use event-hub.
```js
const { def } = require('classcaps')
const EventHub = require('event-hub')def('event-hub', EventHub)
```# License
MIT