pub trait SwiftUiBuilder: Sized {
// Required methods
fn params<M>(self, params: impl IntoReactive<String, M>) -> Self;
fn state_key(self, key: impl Into<String>) -> Self;
}Expand description
Required Methods§
Sourcefn params<M>(self, params: impl IntoReactive<String, M>) -> Self
fn params<M>(self, params: impl IntoReactive<String, M>) -> Self
The JSON params string: a constant, a Signal<String>, or a Fn() -> String. When it’s
reactive the hosted view follows it live: each change re-invokes the provider’s body with
the new JSON (@State inside the view survives, see the crate docs).
Sourcefn state_key(self, key: impl Into<String>) -> Self
fn state_key(self, key: impl Into<String>) -> Self
Keep the hosted view’s SwiftUI state across unmount/remount. Without a key, leaving the
piece’s branch (a tab switch, a when() going false, a page navigation) disposes the
hosting view and its @State with it; with one, the native half retains the hosting view
under key and hands the same instance back on the next mount, so sliders, scroll
positions, @State/@StateObject all survive, and the mount’s current params are
re-applied.
The key pins one hosting view for the app’s lifetime, so use it for the handful of views that want persistence, not per-row content. At most one live instance per key: two mounted pieces sharing a key would fight over one native view.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".