Listener
Export an Abstract class o quicly add an isomorphic listener to your own classes
how to use it
Javascript
const Listener = require('@dzeio/listener')
class Test extends Listener {
public pouet() {
this.emit('eventName')
}
}
exports.default = Test
const Test = require('./Test')
const test = new Test()
test.on('eventName', () => {
console.log('Event Ran')
})
test.pouet()
TS
import Listener from '@dzeio/listener'
export default class Test extends Listener<
eventName: () => void
> {
public pouet() {
this.emit('eventName')
}
}
import Test from './Test'
const test = new Test()
test.on('eventName', () => {
console.log('Event Ran')
})
test.pouet()