Utils/src/signal.ts

13 lines
285 B
TypeScript
Raw Normal View History

2020-10-14 23:48:52 +00:00
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);
});
}
}