This commit is contained in:
taro 2025-03-22 12:01:11 -03:00
parent 20293bd028
commit cc3bc45a2c
1 changed files with 19 additions and 0 deletions

19
src/utils/onUserId.js Normal file
View File

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