25 lines
531 B
JavaScript
25 lines
531 B
JavaScript
|
|
/** @type {Map<string, ()=>Promise<void>} */
|
|
const Files = new Map();
|
|
|
|
globalThis.MODULE = {};
|
|
|
|
/** @type {(file:string, hnadler:()=>void)} */
|
|
export function Register(file, handler)
|
|
{
|
|
console.log("registering", file);
|
|
const WrapperHandler =()=> import(file+"?"+new Date().getTime()).then(handler);
|
|
Files.set(file, WrapperHandler);
|
|
}
|
|
|
|
const Loop =async()=>
|
|
{
|
|
console.log("looping!");
|
|
for (const [fileName, handler] of Files.entries())
|
|
{
|
|
await handler();
|
|
}
|
|
setTimeout(Loop, 3000);
|
|
}
|
|
|
|
Loop(); |