import axios, { AxiosRequestConfig } from 'axios'; class LoadTask { loaded: boolean = false; promise?: Promise; url: string; config?: AxiosRequestConfig; constructor(url: string, config?: AxiosRequestConfig) { this.url = url; this.config = config; } load() { if (this.promise) return this.promise; return (this.promise = axios.get(this.url, this.config)); } static list: Promise[] = []; static push(...tasks: LoadTask[]) { this.list.push(...tasks.map(v => v.load())); } static onEnd(): Promise { return Promise.all(LoadTask.list) as Promise; } } export default function load() {}