local Binding = require(script.Parent.Binding)
local function createRef()
local binding, _ = Binding.create(nil)
local ref = {}
setmetatable(ref, {
__index = function(_self, key)
if key == "current" then
return binding:getValue()
else
return binding[key]
end
end,
__newindex = function(_self, key, value)
if key == "current" then
error("Cannot assign to the 'current' property of refs", 2)
end
binding[key] = value
end,
__tostring = function(_self)
return ("RoactRef(%s)"):format(tostring(binding:getValue()))
end,
})
return ref
end
return createRef