Created
April 12, 2020 05:36
-
-
Save SagnikPradhan/65c0c974441ca3c192e7cbdd1c9fd0ba to your computer and use it in GitHub Desktop.
Using EventEmitter3 with Typescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {EventEmitter} from 'eventemitter3'; | |
interface EventsMap { | |
// EventName: Params[] | |
hello: [string]; | |
} | |
class MyClass extends EventEmitter { | |
constructor() { | |
super(); | |
this.emit('hello', 'Hello World'); | |
} | |
} | |
const myClassInstance = new MyClass(); | |
myClassInstance.on('hello', console.log); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment