
- 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!
29 lines
445 B
Text
29 lines
445 B
Text
--!strict
|
|
--!optimize 2
|
|
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,
|
|
}
|