1
0
silverbullet/plugos-syscall/event.ts
2022-04-19 16:54:47 +02:00

21 lines
455 B
TypeScript

import { syscall } from "./syscall";
export async function dispatch(
eventName: string,
data: any,
timeout?: number
): Promise<any[]> {
return new Promise((resolve, reject) => {
let timeOut = setTimeout(() => {
console.log("Timeout!");
reject("timeout");
}, timeout);
syscall("event.dispatch", eventName, data)
.then((r) => {
clearTimeout(timeOut);
resolve(r);
})
.catch(reject);
});
}