import { watch } from 'vue'; import { useUserStore } from 'stores/user'; const userStore = useUserStore(); export const onUserId = (cb) => watch( () => userStore?.user?.id, async userId => { if (!userId) return; try { await cb(userId); } catch (error) { console.error(error); } }, { immediate: true } );