2023-05-08 03:01:17 +02:00
|
|
|
<template>
|
2023-05-08 03:34:48 +02:00
|
|
|
<slot v-if="loading" name="loader">
|
2024-06-20 09:27:59 +02:00
|
|
|
<LoaderAnimation />
|
2023-05-08 03:34:48 +02:00
|
|
|
</slot>
|
2023-05-08 18:04:30 +02:00
|
|
|
<slot v-else-if="error" name="error">
|
2024-06-20 09:27:59 +02:00
|
|
|
<FetchError :url="props.url" />
|
2023-05-08 03:01:17 +02:00
|
|
|
</slot>
|
2023-05-08 18:04:30 +02:00
|
|
|
<slot v-else> </slot>
|
2023-05-08 03:01:17 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2024-06-20 09:27:59 +02:00
|
|
|
import LoaderAnimation from './LoaderAnimation.vue';
|
|
|
|
import FetchError from './FetchError.vue';
|
2023-05-08 03:01:17 +02:00
|
|
|
|
2024-06-20 09:27:59 +02:00
|
|
|
import { useFetchAndCache } from '../composables/fetchAndCache';
|
2023-05-08 03:01:17 +02:00
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
url: {
|
2024-06-20 09:27:59 +02:00
|
|
|
default: '',
|
2023-05-08 03:01:17 +02:00
|
|
|
required: true,
|
|
|
|
type: String,
|
|
|
|
},
|
2023-05-08 11:19:41 +02:00
|
|
|
cacheName: {
|
|
|
|
required: true,
|
|
|
|
type: String,
|
|
|
|
},
|
|
|
|
alreadyKnownData: Object,
|
2023-05-08 03:01:17 +02:00
|
|
|
});
|
|
|
|
|
2024-06-20 09:27:59 +02:00
|
|
|
const emits = defineEmits(['loaded', 'error', 'loading']);
|
2023-05-08 03:01:17 +02:00
|
|
|
|
2024-06-20 09:27:59 +02:00
|
|
|
const { loading, error } = useFetchAndCache(props.url, {
|
|
|
|
emits: emits,
|
|
|
|
cacheName: props.cacheName,
|
|
|
|
});
|
2023-05-08 03:01:17 +02:00
|
|
|
</script>
|