deno-musings/test_sockets.mjs

25 lines
531 B
JavaScript
Raw Normal View History

2024-10-12 12:28:41 -04:00
/** @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();