RoomClient: predictions property
Available since
@irtio/client 5.0BrowsersNodeThe predictions read-only property of the RoomClient interface is every Prediction that predict() made on the client.
Value
A read-only Set of Prediction objects, in the order they were made. It includes stopped predictions, since they still reconcile with the room’s state.
Description
Only one prediction runs on a client at a time: predict() throws while another hasn’t been stopped. predictions lets code that didn’t make the prediction, such as a debug panel, find it.
Examples
Showing mispredictions in a debug panel
A debug panel lists each prediction’s last tick, its misprediction count and its drift verdict.
// drift-panel.ts
import type { RoomClient } from "@irtio/client";
export function mispredictionReport(room: RoomClient): string[] {
return [...room.predictions].map((p) => `tick ${p.tick}: ${p.mispredictions} mispredictions, ${p.drift.verdict}`);
}
See also
Runtime availability
| Browsers | Node | |
|---|---|---|
predictions | 5.0 | 5.0 |