Refactor into useLocalizedData

This commit is contained in:
BlossomiShymae
2024-10-14 19:02:06 -05:00
parent 793cd3e120
commit e956f7f6d1
15 changed files with 43 additions and 103 deletions

View File

@@ -0,0 +1,12 @@
export default async function useLocalizedData<T>(producer: (locale: string) => Promise<T>) {
const { currentLocale } = useLocale();
const data = ref(await producer(currentLocale.value));
watch(currentLocale, async () => {
data.value = await producer(currentLocale.value);
});
return {
currentLocale,
data
};
}