1234567891011121314151617181920 |
- class Wait<T = void> {
- private _resolve: ((value: T) => void) | null = null;
- public wait(): Promise<T> {
- return new Promise(resolve => this._resolve = resolve);
- }
- public resolve(value: T): void {
- if (this._resolve) {
- this._resolve(value);
- this.dispose();
- }
- }
- public dispose():void{
- this._resolve=null;
- }
- }
- export default function get_new_wait<T = void>(): Wait<T> {
- return new Wait<T>();
- }
|