fn

until

v0.0.14testeddemo

Promised 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

T

Parameters

ParameterTypeDescription
rWatchSource<T> | MaybeRefOrGetter<T>The reactive source to watch

Returns

UntilValueInstance<T> | UntilArrayInstance<T>A chainable instance exposing toBe, toBeTruthy, toBeNull, toBeUndefined, toBeNaN, toMatch, toContains, changed, changedTimes, and the not negation