macro_rules! web_app {
($state_ty:ty, $build:expr $(,)?) => { ... };
($state_ty:ty, $state_init:expr, $build:expr $(,)?) => { ... };
}Expand description
The browser counterpart of android_app!/ios_app!: binds a
Component’s state and build closure to the browser shell’s wasm-bindgen
entry point. Takes the identical two-argument (state type + build
expression, state built via Default) / three-argument (state type +
explicit state-init expression + build expression) shape
android_app! does, and app! drives it through the three-argument form
exactly the way it drives android_app!/ios_app! (see @emit_mobile
below) — most apps reach this through app!/web_app! rather than
hand-writing the explicit state_init form.
Expands to two #[cfg(target_arch = "wasm32")] functions — so, like
ios_app!, the invocation itself is unconditional and self-gating:
calling web_app! off wasm32 expands to nothing. __frust_web_start is
#[wasm_bindgen(start)] — wasm-bindgen’s own module-init entry point, run
once when the browser instantiates the compiled .wasm — and its body is
a single call into __frust_web_run, kept deliberately separate: feeding
wasm_bindgen’s attribute macro a body built straight out of
$state_init/$build (closures that can carry a macro-substituted
$($setup)? block nested inside another closure — see app!’s
@emit_mobile arm) trips its own re-parse of the function into a spurious
syntax error on that nested-block shape; a plain, macro-fragment-free call
is all it ever sees. __frust_web_run carries the real work, in order:
- [
__web_bootstrap]: installs the panic hook and console log sink. - [
__web_init_state]: brings up thefrust_reactive::ReactiveRuntimeand runs$state_initunder its root owner — the point at which asetup = { .. }block bundled into$state_initbyapp!(see@emit_mobile) runs, identically ordered to every other platform. - Hands the initialized state and
$buildtofrust_shell_web::run_app(via the hidden [__frust_shell_web] re-export) — the browser shell’s own entry point, which owns the canvas-bound event loop and therequestAnimationFrameframe pipeline (see [__frust_shell_web]’s doc comment for the contract).