| 320 | } |
| 321 | |
| 322 | notifyGot(key: string): void { |
| 323 | let waits = this.waits.get(key); |
| 324 | if (!waits) { |
| 325 | return; |
| 326 | } |
| 327 | waits = waits.slice().reverse(); |
| 328 | let i = waits.length; |
| 329 | while (i--) { |
| 330 | waits[i].resolve(this.get(key)); |
| 331 | if (waits[i].once) { |
| 332 | waits.splice(i, 1); |
| 333 | } |
| 334 | } |
| 335 | if (waits.length > 0) { |
| 336 | this.waits.set(key, waits); |
| 337 | } else { |
| 338 | this.waits.delete(key); |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | setWait(key: string, resolve: (data: any) => void, once?: boolean) { |
| 343 | const waits = this.waits.get(key); |