Why is there no isWatchSource utility? #13601
Unanswered
DerZade
asked this question in
Help/Questions
Replies: 0 comments 1 reply
-
This is my impl. of /**
* Checks if a value is a valid watch source.
* @param val The value to check if it is a watch source.
* @returns True if the value is a watch source, false otherwise.
*/
function isWatchSource<T>(
val: MaybeRefOrGetter<T | null>,
): val is WatchSource<T | null> {
if (isRef(val)) return true;
if (isReactive(val)) return true;
if (typeof val === 'function') return true;
return false;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When writing composables it's always nice to use
MaybeRefOrGetter
. But if I then want to usewatch
in that composable, I always have to check if it is actually a valid watch source:Would be nice to have a
isWatchSource
utility similar toisRef
orisReactive
:Beta Was this translation helpful? Give feedback.
All reactions