mirror of
https://github.com/BlossomiShymae/clean-cuts.git
synced 2025-12-06 10:10:47 +01:00
Refactor into useLocalizedData
This commit is contained in:
12
composables/useLocalizedData.ts
Normal file
12
composables/useLocalizedData.ts
Normal 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
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user