Monorepo with yarn workspaces requires yarn 3.2
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { syscall } from "./syscall";
|
||||
|
||||
export async function dispatch(
|
||||
eventName: string,
|
||||
data: any,
|
||||
timeout?: number
|
||||
): Promise<any[]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
let timeouter: any = -1;
|
||||
if (timeout) {
|
||||
timeouter = setTimeout(() => {
|
||||
console.log("Timeout!");
|
||||
reject("timeout");
|
||||
}, timeout);
|
||||
}
|
||||
syscall("event.dispatch", eventName, data)
|
||||
.then((r) => {
|
||||
if (timeouter !== -1) {
|
||||
clearTimeout(timeouter);
|
||||
}
|
||||
resolve(r);
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user