diff --git a/interactor.js b/interactor.js index 5c9997f..035094c 100644 --- a/interactor.js +++ b/interactor.js @@ -8,7 +8,10 @@ export class Interactor { constructor(initialReaction = new Reaction()) { this.#actions.listen((action) => { - this[`_handle${action.constructor.name}`](action); + let funcRef = `_handle${action.constructor.name}`; + if (!this[funcRef]) + throw `${this.constructor.name} does not have a handler defined for the action "${action.constructor.name}". Create one by adding a function definition named "${funcRef}" in the ${this.constructor.name} class.`; + this[funcRef](action); }); this._react(initialReaction); } diff --git a/package.json b/package.json index f51c54d..1c44efc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "interactor", - "version": "1.1.2", + "version": "1.1.3", "description": "Cross-element communications and state management utility.", "author": "Bryce Thorup", "type": "module",