
+ Added pesde support + Added `.search()` to `ref` and made `ref()` (`.set_ref()`) & `.search()` return a clearer which removes the reference + Bumped to 0.1.6
29 lines
446 B
Text
29 lines
446 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,
|
|
}
|