fix: Refs and cmd buffers, add unit tests, v0.1.0

- Refs and command buffers used to share data with every single world, this is now mitigated by using a separate data set for every world

- Working unit tests have been added

- jecs-utils has now been released at mark-marks/jecs-utils@v0.1.0!
This commit is contained in:
Mark Marks 2024-09-22 00:50:30 +02:00
parent 9a0aa37667
commit 5a043b2912
4 changed files with 92 additions and 52 deletions

View file

@ -4,15 +4,26 @@ local jecs = require("./jecs")
local WORLD: jecs.World
local listeners: { (jecs.World) -> () } = {}
local function get(): jecs.World
return WORLD
end
local function set(world: jecs.World)
WORLD = world
for _, fn in listeners do
fn(world)
end
end
local function on_set(fn: (jecs.World) -> ())
table.insert(listeners, fn)
end
return {
get = get,
set = set,
on_set = on_set,
}