6 Commits

Author SHA1 Message Date
ad774185c2 Merge pull request 'proper ref to namespaced package' (#13) from 1.1.5 into main
All checks were successful
Push to main / publish (push) Successful in 11s
Reviewed-on: #13
2025-11-07 14:09:50 -07:00
c513a54717 proper ref to namespaced package
All checks were successful
Pull request change / publish (pull_request) Successful in 11s
2025-11-07 14:09:12 -07:00
7e53db5785 Merge pull request 'make scoped' (#12) from 1.1.4 into main
All checks were successful
Push to main / publish (push) Successful in 13s
Reviewed-on: #12
2025-11-07 14:00:01 -07:00
f463dec7f1 make scoped
All checks were successful
Pull request change / publish (pull_request) Successful in 11s
2025-11-07 13:59:07 -07:00
7f55ae0d4e Merge pull request 'added better error handling for missing action handlers' (#11) from 1.1.3 into main
All checks were successful
Push to main / publish (push) Successful in 12s
Reviewed-on: #11
2025-11-06 18:47:04 -07:00
6f52c56857 added better error handling for missing action handlers
All checks were successful
Pull request change / publish (pull_request) Successful in 10s
2025-11-06 18:44:04 -07:00
2 changed files with 8 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
import { Stream } from "stream";
import { Stream } from "@brycethorup/stream";
export class Interactor {
#actions = new Stream();
@@ -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);
}

View File

@@ -1,11 +1,11 @@
{
"name": "interactor",
"version": "1.1.2",
"name": "@brycethorup/interactor",
"version": "1.1.5",
"description": "Cross-element communications and state management utility.",
"author": "Bryce Thorup",
"type": "module",
"main": "interactor.js",
"dependencies": {
"stream": "^1.0.1"
"@brycethorup/stream": "^1.0.1"
}
}