2018-12-28 18:21:45 +02:00
|
|
|
local Event = require 'utils.event_core'
|
2018-11-26 03:07:03 +02:00
|
|
|
local Token = require 'utils.token'
|
2018-06-09 12:43:37 +02:00
|
|
|
|
2018-07-04 17:22:26 +02:00
|
|
|
local Global = {}
|
2018-06-09 12:43:37 +02:00
|
|
|
|
|
|
|
function Global.register(tbl, callback)
|
|
|
|
local token = Token.register_global(tbl)
|
2019-01-16 20:44:55 +02:00
|
|
|
|
|
|
|
Event.on_load(
|
|
|
|
function()
|
|
|
|
callback(Token.get_global(token))
|
|
|
|
end
|
|
|
|
)
|
2018-06-17 12:39:55 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function Global.register_init(tbl, init_handler, callback)
|
|
|
|
local token = Token.register_global(tbl)
|
2018-06-09 12:43:37 +02:00
|
|
|
|
2019-01-16 20:44:55 +02:00
|
|
|
Event.on_init(
|
|
|
|
function()
|
|
|
|
init_handler(tbl)
|
|
|
|
callback(tbl)
|
2018-06-17 12:39:55 +02:00
|
|
|
end
|
2019-01-16 20:44:55 +02:00
|
|
|
)
|
2018-06-17 12:39:55 +02:00
|
|
|
|
2019-01-16 20:44:55 +02:00
|
|
|
Event.on_load(
|
|
|
|
function()
|
|
|
|
callback(Token.get_global(token))
|
2018-06-09 12:43:37 +02:00
|
|
|
end
|
2019-01-16 20:44:55 +02:00
|
|
|
)
|
|
|
|
end
|
2018-06-09 12:43:37 +02:00
|
|
|
|
|
|
|
return Global
|