ViewGuard beta
Class of @v12-engine/client
export declare class ViewGuardKeeps the frame going when a game's own code in it throws. The client runs the game's view every frame: its renderers, its plates, the words it floats, its status lines, its card. One of them that throws is said once in the log (category view), by its name, and is skipped from then on: what it decided is decided as if the game had said nothing (the client's own plate, no status lines, the card as the client makes it), and the rest is drawn.
Skipped for good, not tried again every frame: what throws once throws sixty times a second, and the log, and the frame, would be full of it.
Members
constructor
constructor(log: Logger);Constructs a new instance of the ViewGuard class
fail
fail(part: string, error: unknown): void;Says that part threw, the first time, and skips it from then on
failed
readonly failed: Set<string>;The parts of the view skipped since they threw, by name: status, renderers[0], on[1] (waveStarted)
run
run(part: string, run: () => void): void;Runs run unless part threw before; says so and skips it from then on when it throws now
wrap
wrap<F extends (...args: any[]) => any>(part: string, run: F, fallback: F): F;A function of the view, guarded: what it gives back while it works, what fallback gives back once it has thrown. Up to three arguments, passed on as they are (no array made for them: some are asked hundreds of times a frame)