Lucien Cartier-Tilet
d54aabd621
All checks were successful
deploy / deploy (push) Successful in 2m24s
This commit removes dependency on rxjs. It also implements better composables to handle data fetching from remote APIs and caching these values more transparently. This commit also switches from yarn to npm It also switches to the official Umami plugin
37 lines
759 B
Vue
37 lines
759 B
Vue
<template>
|
|
<slot v-if="loading" name="loader">
|
|
<LoaderAnimation />
|
|
</slot>
|
|
<slot v-else-if="error" name="error">
|
|
<FetchError :url="props.url" />
|
|
</slot>
|
|
<slot v-else> </slot>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import LoaderAnimation from './LoaderAnimation.vue';
|
|
import FetchError from './FetchError.vue';
|
|
|
|
import { useFetchAndCache } from '../composables/fetchAndCache';
|
|
|
|
const props = defineProps({
|
|
url: {
|
|
default: '',
|
|
required: true,
|
|
type: String,
|
|
},
|
|
cacheName: {
|
|
required: true,
|
|
type: String,
|
|
},
|
|
alreadyKnownData: Object,
|
|
});
|
|
|
|
const emits = defineEmits(['loaded', 'error', 'loading']);
|
|
|
|
const { loading, error } = useFetchAndCache(props.url, {
|
|
emits: emits,
|
|
cacheName: props.cacheName,
|
|
});
|
|
</script>
|