@prof-dev/event-emitter
v1.0.9
Published
Helper class for events management
Downloads
2
Readme
EventEmitter
Helper class for easy events management
Examples
class MyClass extends EventEmitter<"open"> {}
class MyClass extends EventEmitter<"open" | "close", MyClass> {
constructor() {
super();
}
open() {
this.dispatch("open", this);
}
close() {
this.dispatch("close", this);
}
}
const obj = new MyClass();
const onOpen = () => {
obj.off("open", onOpen);
};
obj.on("open", onOpen);
obj.once("close", () => {});