Window event for next.
npm install -S @jswork/next-global-event
api | params | description |
---|---|---|
on | (name, handler) | Attach event. |
emit | (name, data) | Trigger event. |
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 });
Code released under the MIT license.