Interface: ReportGuard
API / @xmachines/play-view / index / ReportGuard
Defined in: packages/play-view/src/report-guard.ts:23
A report guard of one provider.
The rule it holds: a provider reports a contained failure to the host, and it must do that without letting the host defeat the containment. Two things follow — a reset that the host calls from INSIDE the report does nothing, because no input changed between the two attempts; and every callback that the provider handed out does nothing once the provider is gone, because a host can keep a reset (a “Retry” button of a toast outlives the route that opened it).
Methods
blocked()
blocked(): boolean;Defined in: packages/play-view/src/report-guard.ts:25
True when a reset that the host starts must do nothing.
Returns
boolean
dispose()
dispose(): void;Defined in: packages/play-view/src/report-guard.ts:38
The provider is gone.
Returns
void
disposed()
disposed(): boolean;Defined in: packages/play-view/src/report-guard.ts:36
True once ReportGuard.dispose ran, and never for a report that runs.
ReportGuard.blocked answers a different question: it is true for the
re-entry of a report as well, and it goes back to false when that report ends. A
caller that asks whether the guard is SPENT — play-react builds one again after the
cleanup of <StrictMode> disposed it — must read this one: blocked() there would
replace a live guard that is reporting, and the finally of that report would then
clear the re-entry flag of a guard that nobody holds.
Returns
boolean
report()
report(error, deliver): void;Defined in: packages/play-view/src/report-guard.ts:50
Delivers one report, with the re-entry flag held for the call.
Parameters
| Parameter | Type | Description |
|---|---|---|
error | unknown | The contained failure. |
deliver | (() => void) | undefined | The call of the handler of the host, or undefined when the host gave none. Without a handler the guard writes ReportGuardMessages.noHandler to console.error: a contained failure that reaches no handler and no caller is the one result that nobody can debug. A handler that THROWS is contained where the guard carries ReportGuardMessages.handlerThrew, and it reaches the caller where it does not. |
Returns
void