https://github.com/antvis/event-emitter
Simple event emitter for @antvis
https://github.com/antvis/event-emitter
ee event-emitter
Last synced: about 1 year ago
JSON representation
Simple event emitter for @antvis
- Host: GitHub
- URL: https://github.com/antvis/event-emitter
- Owner: antvis
- Created: 2019-07-19T02:17:31.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-02-10T09:43:00.000Z (over 4 years ago)
- Last Synced: 2025-04-13T06:17:11.257Z (about 1 year ago)
- Topics: ee, event-emitter
- Language: TypeScript
- Homepage:
- Size: 13.7 KB
- Stars: 20
- Watchers: 3
- Forks: 13
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @antv/event-emitter
> event-emitter for @antvis.
## Install
> npm i --save @antv/event-emitter
## Usage
```js
import EE from '@antv/event-emitter';
const ee = new EE();
ee.on('mouseover', () => {});
ee.once('click', () => {});
ee.on('*', () => {});
ee.emit('click', 1, 'hello', true);
ee.off('click');
```
## API
Simple and similar with `event-emitter`.
- `on(evt: string, callback: Function)`: listen an event.
- `once(evt: string, callback: Function)`: listen a event only once.
- `emit(evt: string, ...parameters: any[])`: emit / trigger an event with parameters.
- `off(evt?: string, callback?: Function)`: unsubscribe an event.
- `getEvents()`: get all the exist events.