Files
vikunja/frontend/src/helpers/createAsyncComponent.ts
Dominik Pschenitschni 454418ee63 chore: fix indentation
2025-06-19 10:53:35 +02:00

22 lines
679 B
TypeScript

import { defineAsyncComponent, type AsyncComponentLoader, type AsyncComponentOptions, type Component, type ComponentPublicInstance } from 'vue'
import ErrorComponent from '@/components/misc/Error.vue'
import LoadingComponent from '@/components/misc/Loading.vue'
const DEFAULT_TIMEOUT = 60000
export function createAsyncComponent<T extends Component = {
new (): ComponentPublicInstance;
}>(source: AsyncComponentLoader<T> | AsyncComponentOptions<T>): T {
if (typeof source === 'function') {
source = { loader: source }
}
return defineAsyncComponent({
...source,
loadingComponent: LoadingComponent,
errorComponent: ErrorComponent,
timeout: DEFAULT_TIMEOUT,
})
}