Skip to content

ClockPort

export interface ClockPort extends ActivityPort, DisposablePort {
onHeartbeat(cb: () => void): void;
}

A port to detect external events (pointer operations, resizes, etc.) and wake up the simulator. By passing it to Simulator.add(), the simulation loop restarts when an event occurs.

MethodDescription
onHeartbeat(cb)Registers a callback to be called when an event occurs
isActive()Returns true if the clock is currently firing events (from ActivityPort)
destroy()Releases event listeners (from DisposablePort)

Inherits from ActivityPort and DisposablePort. When the Simulator is paused and receives a heartbeat, it calls wake() to restart the loop. Use ClockComposer when combining multiple Clocks.