This is my current implementation of an event emitter.
class Table {
set onDiscard(cb) {
this._onDiscard = cb;
}
notifyDiscard(s) {
if (this._onDiscard) {
this._onDiscard(s);
}
}
}
In the case of having multiple events this gets a burden.
What library/feature/implementation can I use so I can simplify this to a single line.
Aucun commentaire:
Enregistrer un commentaire