Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Builds Vue composables accepting plain values, refs, or getters via MaybeRef and MaybeRefOrGetter, normalized with toValue and toRef.
0% 50%+50 ptsof test cases passed
Passed 11 of 22 test cases with the skill, and 0 of 22 without it.
3 of 3 safety checks passed
Not used yet
Adaptable composables are reusable functions that can accept both reactive and non-reactive inputs. This allows developers to use the composable in a variety of contexts without worrying about the reactivity of the inputs.
Steps to design an adaptable composable in Vue.js:
toValue() or toRef() to normalize inputs inside reactive effects./**
* value or writable ref (value/ref/shallowRef/writable computed)
*/
export type MaybeRef<T = any> = T | Ref<T> | ShallowRef<T> | WritableComputedRef<T>;
/**
* MaybeRef<T> + ComputedRef<T> + () => T
*/
export type MaybeRefOrGetter<T = any> = MaybeRef<T> | ComputedRef<T> | (() => T);
MaybeRefOrGetterMaybeRefMaybeRefOrGetter, or you may accidentally invoke it as a getter.MaybeRefOrGetter.When MaybeRefOrGetter or MaybeRef is used:
toRef() (e.g. watcher source)toValue()Adaptable useDocumentTitle Composable: read-only title parameter
Next to this one in the catalogue, plus more from the same author.