(
entry: Entry,
server: AsyncResult.AsyncResult<any, any>
)
| 5570 | } |
| 5571 | /** The server value with every patch applied in issue order. A patch that throws is dropped from the entry. */ |
| 5572 | const patchedViewOf = ( |
| 5573 | entry: Entry, |
| 5574 | server: AsyncResult.AsyncResult<any, any> |
| 5575 | ): PatchedView => { |
| 5576 | if (entry.patches.length === 0 || server._tag !== "Success") { |
| 5577 | return { result: server, patched: false } |
| 5578 | } |
| 5579 | let value = server.value |
| 5580 | for (const rec of entry.patches.slice()) { |
| 5581 | try { |
| 5582 | value = applyPatch( |
| 5583 | rec.patch, |
| 5584 | entry.def.name, |
| 5585 | entry.argsKey, |
| 5586 | entry.args, |
| 5587 | value |
| 5588 | ) |
| 5589 | } catch { |
| 5590 | entry.patches = entry.patches.filter((other) => other !== rec) |
| 5591 | } |
| 5592 | } |
| 5593 | if (entry.patches.length === 0) return { result: server, patched: false } |
| 5594 | return { |
| 5595 | result: AsyncResult.success(value, { |
| 5596 | waiting: server.waiting, |
| 5597 | timestamp: server.timestamp |
| 5598 | }), |
| 5599 | patched: true |
| 5600 | } |
| 5601 | } |
| 5602 | /** Quiet over a cold entry, and skips a state equal to a watcher's last. */ |
| 5603 | const emit = (entry: Entry): void => { |
| 5604 | if (entry.watchers.size === 0) return |
no test coverage detected