Make iterators simple functions
Some checks are pending
analysis / Run Luau Analyze (push) Waiting to run
deploy-docs / build (push) Waiting to run
deploy-docs / Deploy (push) Blocked by required conditions
publish-npm / publish (push) Waiting to run
unit-testing / Run Luau Tests (push) Waiting to run

This commit is contained in:
Ukendio 2025-07-06 09:52:06 +02:00
parent 169ec09ed5
commit 23540e5919

View file

@ -51,8 +51,7 @@ local function observers_new(world, query, callback)
world:changed(term, emplaced)
end
return setmetatable({}, {
__iter = function()
return function()
local row = i
return function()
if row == 0 then
@ -64,7 +63,6 @@ local function observers_new(world, query, callback)
return entity
end
end
})
end
local function join(world, component)
@ -152,6 +150,19 @@ local function monitors_new(world, query, callback)
world:added(term, emplaced)
world:removed(term, removed)
end
return function()
local row = i
return function()
if row == 0 then
i = 0
table.clear(entities)
end
local entity = entities[row]
row -= 1
return entity
end
end
end
local function observers_add(world: jecs.World): PatchedWorld