import { WatchSource, watch } from 'vue'; export function waitForValueChange(valueWatcher: WatchSource, timeoutMs = 2000): Promise { return new Promise((resolve, reject) => { const unwatch = watch(valueWatcher, (newValue, oldValue) => { if (newValue !== oldValue) { unwatch(); resolve(newValue); } }, { immediate: false }); setTimeout(() => { unwatch(); reject(new Error('Timeout waiting for value to change.')); }, timeoutMs); }); }