2022-04-01 15:07:08 +00:00
|
|
|
import { syscall } from "./syscall";
|
|
|
|
|
2022-04-19 14:54:47 +00:00
|
|
|
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
|
|
|
}
|