Skip to main content
The client stores the latest snapshot in memory. Read it synchronously with getView() and subscribe to know when to render again.

Render the current view

Call render() once after subscribing. subscribe only calls the listener for future snapshots or status changes. The listener receives no arguments. Read all current values from the client inside it.

Clean up subscriptions

Both subscription methods return an unsubscribe function:

Refresh available actions

Available commands are not part of the state view. Ask for them after a ready snapshot:
Treat this list as presentation guidance. The engine validates every submitted command again.

Render hidden values

Private fields are typed as the real value or a hidden envelope:

Listen for events

Use events for transient effects such as animations, sounds, and activity messages:
Events are not a replacement for state. A frontend that reconnects receives the current view, not every past event.

Track connection state

getStatus() returns:
  • connecting before the first snapshot.
  • ready when requests can be sent.
  • reconnecting while a local event stream retries.
  • error after an unrecoverable connection problem.
  • closed after the host ends the game or you call dispose().
Use getStateVersion() when you need to identify the snapshot currently rendered. It returns null before the first view.