https://github.com/afeiship/next-global-event
Window event for next.
https://github.com/afeiship/next-global-event
custom-event dispatch-event event global next window
Last synced: about 2 months ago
JSON representation
Window event for next.
- Host: GitHub
- URL: https://github.com/afeiship/next-global-event
- Owner: afeiship
- License: mit
- Created: 2021-03-19T09:01:00.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-19T10:22:46.000Z (over 5 years ago)
- Last Synced: 2025-10-24T01:51:39.576Z (8 months ago)
- Topics: custom-event, dispatch-event, event, global, next, window
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# next-global-event
> Window event for next.
[![version][version-image]][version-url]
[![license][license-image]][license-url]
[![size][size-image]][size-url]
[![download][download-image]][download-url]
## installation
```bash
npm install -S @jswork/next-global-event
```
## apis
| api | params | description |
| ---- | --------------- | -------------- |
| on | (name, handler) | Attach event. |
| emit | (name, data) | Trigger event. |
## usage
```js
import NxGlobalEvent from '@jswork/next-global-event';
// attach event
const res = NxGlobalEvent.on('panel:ok', (inEvent)=>{
console.log('I am ok');
});
// dettach event
res.destroy();
// trigger event
NxGlobalEvent.emit('panel:ok', { ready: true });
```
## license
Code released under [the MIT license](https://github.com/afeiship/next-global-event/blob/master/LICENSE.txt).
[version-image]: https://img.shields.io/npm/v/@jswork/next-global-event
[version-url]: https://npmjs.org/package/@jswork/next-global-event
[license-image]: https://img.shields.io/npm/l/@jswork/next-global-event
[license-url]: https://github.com/afeiship/next-global-event/blob/master/LICENSE.txt
[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/next-global-event
[size-url]: https://github.com/afeiship/next-global-event/blob/master/dist/next-global-event.min.js
[download-image]: https://img.shields.io/npm/dm/@jswork/next-global-event
[download-url]: https://www.npmjs.com/package/@jswork/next-global-event