@@ -101,6 +101,8 @@ local function observers_add(world: jecs.World & { [string]: any }): PatchedWorl
101
101
102
102
world .added = function (_ , component , fn )
103
103
local listeners = signals .added [component ]
104
+ local component_index = world .component_index :: jecs .ComponentIndex
105
+ assert (component_index [component ] == nil , "You cannot use hooks on components you intend to use this signal with" )
104
106
if not listeners then
105
107
listeners = {}
106
108
signals .added [component ] = listeners
@@ -115,6 +117,8 @@ local function observers_add(world: jecs.World & { [string]: any }): PatchedWorl
115
117
116
118
world .changed = function (_ , component , fn )
117
119
local listeners = signals .emplaced [component ]
120
+ local component_index = world .component_index :: jecs .ComponentIndex
121
+ assert (component_index [component ] == nil , "You cannot use hooks on components you intend to use this signal with" )
118
122
if not listeners then
119
123
listeners = {}
120
124
signals .emplaced [component ] = listeners
@@ -130,6 +134,8 @@ local function observers_add(world: jecs.World & { [string]: any }): PatchedWorl
130
134
131
135
world .removed = function (_ , component , fn )
132
136
local listeners = signals .removed [component ]
137
+ local component_index = world .component_index :: jecs .ComponentIndex
138
+ assert (component_index [component ] == nil , "You cannot use hooks on components you intend to use this signal with" )
133
139
if not listeners then
134
140
listeners = {}
135
141
signals .removed [component ] = listeners
0 commit comments