Subscribe on changes!

give toref API just like unref

avatar
Sep 18th 2020

What problem does this feature solve?

while unref is sugar for isRef(someVar) ? someVar.value : someVar. why not have toref for sugar: isRef(someVar) ? someVar : ref(someVar)

I know toRef & toRefs, but why ?

What does the proposed API look like?

give toref as a pair of unref. lots of libs make their own wrap and unwrap utils

avatar
Sep 18th 2020

unref is more common because you use it to extract arguments in composition functions that can accept both raw data and refs. On top of that, you don't need to check if the data is a ref when calling ref(data), it should already work

There is already a toRef function BTW