1
0
silverbullet/plugos-syscall/event.ts

21 lines
455 B
TypeScript
Raw Normal View History

2022-04-01 15:07:08 +00:00
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);
});
2022-04-01 15:07:08 +00:00
}