Skip to content

Commit 08a18fc

Browse files
committed
removed duplicate event registration for components on the broker
1 parent 322f2dc commit 08a18fc

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "modular-openscriptjs",
3-
"version": "1.0.18",
3+
"version": "1.0.22",
44
"description": "OpenScriptJs Framework - A lightweight, reactive JavaScript framework for building modern web applications",
55
"type": "module",
66
"main": "./dist/modular-openscriptjs.umd.js",

src/component/Component.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,14 @@ export default class Component {
254254
* Get all Emitters declared in the component
255255
*/
256256
getDeclaredListeners() {
257+
258+
if (this.__ojsRegistered) {
259+
console.warn(
260+
`Component "${this.name}" is already registered. Skipping duplicate registration.`
261+
);
262+
return;
263+
}
264+
257265
let obj = this;
258266
let seen = new Set();
259267
const h = container.resolve("h");

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const loader = new AutoLoader();
3535
const autoload = new AutoLoader();
3636
const h = MarkupHandler.proxy();
3737

38+
3839
// Register global instances in container
3940
container.value("broker", broker);
4041
container.value("router", router);
@@ -43,6 +44,7 @@ container.value("mediatorManager", mediatorManager);
4344
container.value("loader", loader);
4445
container.value("autoload", autoload);
4546
container.value("h", h);
47+
container.value("component", component);
4648

4749
let ojsRouterEvents = {
4850
ojs: {

0 commit comments

Comments
 (0)