mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Also fixed potential bug with `create()` being called recursively if a property binding passed as a property to `create()` also calls `create()`
25 lines
466 B
Text
25 lines
466 B
Text
type Action = {
|
|
priority: number,
|
|
callback: (Instance) -> ()
|
|
}
|
|
|
|
local ActionMT = table.freeze {}
|
|
|
|
local function is_action(v: any)
|
|
return getmetatable(v) == ActionMT
|
|
end
|
|
|
|
local function action(callback: (Instance) -> (), priority: number?): Action
|
|
local a = {
|
|
priority = priority or 1,
|
|
callback = callback
|
|
}
|
|
|
|
setmetatable(a :: any, ActionMT)
|
|
|
|
return table.freeze(a)
|
|
end
|
|
|
|
return function()
|
|
return action, is_action
|
|
end
|