Lifecycle | AIUI | Rokid

Use lifecycle callbacks to initialize a Page, handle visibility changes, and release resources when it closes. A Page that reaches its first frame calls onLoad → onShow →…

Lifecycle

Use lifecycle callbacks to initialize a Page, handle visibility changes, and release resources when it closes. A Page that reaches its first frame calls onLoad → onShow → onReady. Returning to the same Page calls onShow again.

Lifecycle Callback Table

CallbackDescriptionTrigger Timing
onLoadListens for page loadTriggered when the page loads, once per page instance
onShowListens for page displayTriggered when the page is displayed or brought to the foreground
onReadyListens for the first render completion of the pageAfter the first frame containing the initial view is presented, once per page instance
onHideListens for the page being hiddenTriggered when the page is hidden or moved to the background
onUnloadListens for page unloadTriggered when the page is unloaded

Lifecycle Demo

Sequence: creation onLoad → display onShow → first-frame presentation onReady; later onHide / onShow cycles end with onUnload.

Callback Details

onLoad(Object query)

Runs once per Page instance. Read the parameters supplied when opening the page from query.

onShow()

Triggered when the page is displayed or brought to the foreground.

onReady()

Runs once per instance after the first frame containing the initial view is actually presented. Template parsing or completed layout alone does not trigger onReady. Returning to an existing page and later setData() calls do not repeat it. Instances unloaded before presentation do not receive a late callback.

onHide()

Triggered when the page is hidden or moved to the background.

onUnload()

Runs when the Page instance is destroyed. Clear timers and release resources that belong to the Page in this callback.

Recommended Reading

  • Page Overview
  • Page Definition
  • Events