export class EventBus extends EventTarget { trigger(name: string, payload?: any) { this.dispatchEvent(new CustomEvent(name, { detail: payload })); } } export function whenReady(fn?: any): Promise { return new Promise(function (resolve) { if (document.readyState !== "loading") { resolve(true); } else { document.addEventListener("DOMContentLoaded", resolve, false); } }).then(fn || function () {}); } export async function loadFile(url: string): Promise { const result = await fetch(url); if (!result.ok) { throw new Error("Error while fetching xml templates"); } return await result.text(); }