hedera-web/src/utils/onUserId.js

19 lines
343 B
JavaScript

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 }
);