Skip to main content

run

Function run 

Source
pub fn run<C: Component>(root: C) -> Result<()>
Expand description

Run a root Component in the desktop preview shell until the window closes — the canonical runApp equivalent for the Component model.

root.init() seeds the component’s retained State once; the resulting AnyView<C::State> is then driven through the same desktop preview loop App::run uses, rebuilding from root.build(state) every frame.

Initializes the process-wide frust_reactive::ReactiveRuntime with a no-op waker before root.init() runs, since a signal or context created there must already have a runtime to be created under — the desktop preview loop’s own later ReactiveRuntime::init call swaps in the real proxy waker on top of this seed, the documented swap-on-reinit behavior.

root.init() runs under the runtime’s root [Owner] (via with_owner): init unblocks signal/executor creation, but provide_context/on_cleanup are no-ops unless an Owner is ambient, and a root component has no enclosing component to supply one — so the root component registers against the root owner (process lifetime, never disposed). The desktop loop separately wraps each per-frame rebuild in the same owner.

Desktop-only, matching App::run: on Android the app is driven by android_app!/JNI and on iOS by ios_app!’s C-ABI entry points instead, not by this loop.

Zero-config: the window is DesktopConfig::default()’s. Name the app, its icon or its menu bar with run_desktop_config (or app!’s desktop = { .. } argument) instead.