1.1.2
All checks were successful
Pull request change / publish (pull_request) Successful in 15s

This commit is contained in:
2025-11-06 18:33:33 -07:00
parent 95f85aedaa
commit f8cdfe131f
2 changed files with 30 additions and 4 deletions

View File

@@ -7,9 +7,9 @@ export class Interactor {
#latestReactions = {};
constructor(initialReaction = new Reaction()) {
this.#actions.listen((action) =>
this[`handle${action.constructor.name}`](action)
);
this.#actions.listen((action) => {
this[`_handle${action.constructor.name}`](action);
});
this._react(initialReaction);
}
@@ -45,8 +45,34 @@ export class Interactor {
export class Action {}
export class ActionBundle {
add(action) {
if (!(action.prototype instanceof Action)) {
throw "Only classes extended by `Action` can be added to a `ActionBundle`";
}
let actionName = action.name;
this[`#${actionName}`] = action;
Object.defineProperty(this, actionName, {
get: () => this[`#${actionName}`],
});
}
}
export class Reaction {
equals(reaction) {
return false;
}
}
export class ReactionBundle {
add(reaction) {
if (!(reaction.prototype instanceof Reaction)) {
throw "Only classes extended by `Reaction` can be added to a `ReactionBundle`";
}
let reactionName = reaction.name;
this[`#${reactionName}`] = reaction;
Object.defineProperty(this, reactionName, {
get: () => this[`#${reactionName}`],
});
}
}