RoomClient: update property
Available since
@irtio/client 5.0BrowsersNodeThe update read-only property of the RoomClient interface is the update number of the last state update the client applied.
Value
A number. It’s 0 before the first state update.
Description
The room numbers the state updates it sends. When the client reconnects to the same generation of the room, it sends update so the room resumes from there and sends only what changed since.
The update event fires after each state update with the same number, and stats.lastUpdate gives that update’s size. In a room without ticks, where tick is 0, update is what counts the client’s view.
Examples
Logging updates in a debug overlay
A debug overlay logs each state update’s number, tick and size as it’s applied.
// updates.ts
import type { RoomClient } from "@irtio/client";
export function logUpdates(room: RoomClient): void {
room.addEventListener("update", () => {
const size = room.stats.lastUpdate?.bytes ?? 0;
console.log(`update ${room.update} at tick ${room.tick}, ${size} bytes`);
});
}
See also
Runtime availability
| Browsers | Node | |
|---|---|---|
update | 5.0 | 5.0 |