Skip to main content

fire_on_ready

Function fire_on_ready 

Source
pub fn fire_on_ready<H: ScriptHost + Resource<Mutability = Mutable>>(
    host: ResMut<'_, H>,
    fired: ResMut<'_, OnReadyFired>,
    events: MessageWriter<'_, ScriptCommandEvent>,
)
Expand description

Dispatch the script’s optional on_ready() once per mount, on the first tick after the DOM index is published.

on_start runs at app-construction time, before any tick, when no element is queryable yet: a node_get_by_id there returns 0. That forced DOM apps to defer their first tree build behind a set_timeout("boot", 0) timer. on_ready closes that gap: it runs after the first build_dom_index publish, so a query inside it observes the mounted static tree and the app can build its initial DOM directly. A script without on_ready is a no-op (the host reports the missing handler as not-found), so existing on_start apps are unaffected. Commands on_ready emits flow onto the event bus like any handler’s, and this system is ordered before the DOM-command collector so those mutations apply on the same first tick.