There are often cases where props may be either a source or a raw value. Being able to unwrap a T | Source<T> value into T would help allow developers to accept both static and reactive values in components and composables. The functionality would be similar to unref() from Vue.
local function composable(value: string | Source<string>)
watch(function()
print(unwrap(value)) -- Hello, world!
end)
end
Vue also allows you to pass a ref to ref(), and it will be returned as-is. Being able to normalize a T | Source<T> value to Source<T> would go hand-in-hand with the above proposal.
local function composable(value: string | Source<string>)
local normalized = source(value)
watch(function()
print(normalized()) -- Hello, world!
end)
end
There are often cases where props may be either a source or a raw value. Being able to unwrap a
T | Source<T>
value intoT
would help allow developers to accept both static and reactive values in components and composables. The functionality would be similar tounref()
from Vue.Vue also allows you to pass a ref to
ref()
, and it will be returned as-is. Being able to normalize aT | Source<T>
value toSource<T>
would go hand-in-hand with the above proposal.