Make callback optional

This commit is contained in:
Ukendio 2025-07-05 21:26:05 +02:00
parent 6dfb428296
commit a9891abf6d

View file

@ -7,7 +7,7 @@ export type PatchedWorld = jecs.World & {
observer: <T...>(
PatchedWorld,
jecs.Query<T...>,
(jecs.Entity) -> ()
(<a>(jecs.Entity, jecs.Id<a>, a) -> ())?
) -> () -> (jecs.Entity),
monitor: (
PatchedWorld,
@ -40,7 +40,9 @@ local function observers_new(world, query, callback)
if jecs.query_match(query, archetype) then
i += 1
entities[i] = entity
callback(entity, id, value)
if callback ~= nil then
callback(entity, id, value)
end
end
end