Utils/src/signal.ts
2020-10-15 01:48:52 +02:00

13 lines
285 B
TypeScript

export default class Signal {
awaiter: (() => void)[] = [];
sendSignal(): void {
this.awaiter.forEach((a) => a());
this.awaiter = [];
}
awaitSignal(): Promise<void> {
return new Promise((resolve) => {
this.awaiter.push(resolve);
});
}
}