@cspruit/zephyr
v1.0.10
Published
A lightweight event library
Downloads
27
Readme
Zephyr
Zephyr is a lightweight javascript library that handles events and streams.
Installation
- Install by running
npm install --save @cspruit/zephyr
in the same directory as the package.json file lives.
Usage
For Application events
import {EventRegistry} from '@cspruit/zephyr';
const registry = new EventRegistry();
registry.listen('My Cool Event', () => console.log('Hello world!'));
registry.sendEvent('My Cool Event'); // Should trigger 'Hello world!'
For Element events
- Zephyr provides a wrapper around the normal element.addEventListener function that will filter for specific keypresses and other non-standard event types.
import {listen, EventTypes} from '@cspruit/zephyr';
const submitField = document.createElement('input');
listen(el, EventTypes.enter, () => console.log('enter was pressed!'));
Contributing
All contributions, suggestions, and issues are welcome!
Check out the Issues page. In general anything listed is up for grabs, though bugs tend to be more detailed than enhancements and might be better to pick up if starting out.
License
This project uses GPL 3.0.