fn
until
v0.0.15testeddemoPromised one-time watch for ref / getter changes. Resolve once the source matches a condition, optionally with a timeout.
Examples
ts
const count = ref(0);
await until(count).toBe(7);ts
const ready = ref(false);
await until(ready).toBeTruthy();ts
// negation and timeout
await until(count).not.toBe(0, { timeout: 1000, throwOnTimeout: true });ts
// resolve once the source changes n times
await until(count).changedTimes(3);Demo
Loading demo…
Signatures
ts
export function until<T extends unknown[]>(r: WatchSource<T> | MaybeRefOrGetter<T>): UntilArrayInstance<T>;ts
export function until<T>(r: WatchSource<T> | MaybeRefOrGetter<T>): UntilValueInstance<T>;Type Parameters
TParameters
| Parameter | Type | Description |
|---|---|---|
r | T | import("vue").Ref<T, any> | import("vue").ComputedRef<T> | (() => T) | import("vue").Ref<T, T> | import("vue").ShallowRef<T, T> | import("vue").WritableComputedRef<T, T> | (() => T) | The reactive source to watch |
Returns
UntilValueInstance<T, false> | UntilArrayInstance<T>A chainable instance exposing `toBe`, `toBeTruthy`, `toBeNull`, `toBeUndefined`, `toBeNaN`, `toMatch`, `toContains`, `changed`, `changedTimes`, and the `not` negation