fn
useIsDefined
v0.0.15testeddemoReactive counterpart to {@link isDefined}. Returns a `ComputedRef<boolean>` that re-evaluates whenever the source ref, getter, or plain value resolves to a non-nullish value. Use this when the definedness itself needs to drive reactivity (templates, watchers, derived state); reach for the synchronous {@link isDefined} when you only need a one-off type guard.
Examples
ts
const data = ref<Data | null>(null);
const ready = useIsDefined(data);
watch(ready, isReady => isReady && render());ts
const hasResult = useIsDefined(() => store.result);Demo
Loading demo…
Signature
ts
export function useIsDefined<T>(value: MaybeRefOrGetter<T>): UseIsDefinedReturn{ ... }Type Parameters
TParameters
| Parameter | Type | Description |
|---|---|---|
value | MaybeRefOrGetter<T> | The reactive source (ref, getter, or value) |
Returns
UseIsDefinedReturnA computed boolean, `true` while the source is non-nullish