* buffer multiple hot updates triggered by the same src change * so that they are invoked in the same order they were sent. * (otherwise the order may be inconsistent because of the http request round trip)
(payload: Update)
| 250 | * (otherwise the order may be inconsistent because of the http request round trip) |
| 251 | */ |
| 252 | public async queueUpdate(payload: Update): Promise<void> { |
| 253 | this.updateQueue.push(this.fetchUpdate(payload)) |
| 254 | if (!this.pendingUpdateQueue) { |
| 255 | this.pendingUpdateQueue = true |
| 256 | await Promise.resolve() |
| 257 | this.pendingUpdateQueue = false |
| 258 | const loading = [...this.updateQueue] |
| 259 | this.updateQueue = [] |
| 260 | ;(await Promise.all(loading)).forEach((fn) => fn && fn()) |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | private async fetchUpdate(update: Update): Promise<(() => void) | undefined> { |
| 265 | const { path, acceptedPath, firstInvalidatedBy } = update |
no test coverage detected