App lifecycle
JestSDK.lifecycle reports when the game document is hidden or shown and when the
player asks to leave through Jest's platform controls.
Connect to these signals after SDK initialization. Each signal supports multiple connections; disconnect during teardown:
func _ready():
await JestSDK.init_sdk()
JestSDK.lifecycle.hidden.connect(_on_hidden)
JestSDK.lifecycle.shown.connect(_on_shown)
JestSDK.lifecycle.exit_requested.connect(_on_exit_requested)
func _on_hidden():
game.pause()
audio.pause()
func _on_shown():
game.resume()
audio.resume()
func _on_exit_requested():
save_progress()
func _exit_tree():
JestSDK.lifecycle.hidden.disconnect(_on_hidden)
JestSDK.lifecycle.shown.disconnect(_on_shown)
JestSDK.lifecycle.exit_requested.disconnect(_on_exit_requested)
Keep connections active for the game lifetime, then disconnect during teardown.
JestSDK.lifecycle.hidden
Emitted when the browser changes the game document from visible to hidden, such as when the player switches tabs, backgrounds the browser, or locks the device. It is not emitted for the document's initial visibility state.
Use it to pause the game loop, physics, animation, and audio.
JestSDK.lifecycle.shown
Emitted when the game document changes from hidden back to visible. It is not emitted on
initial startup; await JestSDK.init_sdk() is the startup boundary.
Use it to resume work stopped by hidden, refresh time-sensitive state, and reconcile
elapsed time.
JestSDK.lifecycle.exit_requested
Emitted when the platform begins an exit flow, including its exit control and browser Back or mobile swipe-back navigation that Jest can intercept. It is emitted before the exit confirmation is resolved. The player can still choose to stay, and connected functions cannot cancel or delay navigation.
This signal only represents an exit flow the platform can intercept. Closing the tab, terminating the browser, or an operating-system shutdown may not produce a final signal. Back navigation that leaves the Jest document directly, such as returning to an external referral page, may not produce one either.