Replay: step() method

Available since @irtio/client 5.0BrowsersNode

The step() method of the Replay interface shows the next tick, with its events and recorded messages.

Syntax

step()

Parameters

None.

Return value

A boolean: true if it showed a tick, and false if the replay was already at its last tick.

Exceptions

None.

Description

step() fires a message event for each broadcast recorded in the next tick, applies the tick’s changes and fires the entity and presence callbacks, then fires the tick event. A step that reaches the last tick stops playback and fires the ended event.

Examples

Stepping frame by frame

A replay viewer steps one tick with the period key while paused, to study a close call.

// frame-step.ts
import type { Replay } from "@irtio/client/replay";

export function bindFrameStep(replay: Replay): void {
  addEventListener("keydown", (e) => {
    if (e.key !== "." || replay.playing) return;
    if (!replay.step()) console.log("that was the last tick");
  });
}

See also

Runtime availability

BrowsersNode
step()5.05.0