Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Allow to use defined events only #156

Open
xmedeko opened this issue Nov 30, 2020 · 0 comments
Open

Allow to use defined events only #156

xmedeko opened this issue Nov 30, 2020 · 0 comments

Comments

@xmedeko
Copy link

xmedeko commented Nov 30, 2020

As a defensive programmer 😃 I would welcome a switch to allow to use defined events only. Something like:

var emitter = new EventEmitter();
emitter.defineEvents(["my-event-1", "my-event-2"]);
emitter.setValidating(true); // switch on validations

emitter.addListener("my-event-1", () => {...}); // OK
emitter.addListener("bad-event", () => {...}); // Error
emitter.emit("my-event-1"); // OK
emitter.emit("bad-event"); // Error
// etc. other methods like removeEvent
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant