Skip to main content

on_write

Function on_write 

Source
pub fn on_write(f: impl Fn() + Send + Sync + 'static)
Expand description

Register what to do when a bound control writes.

Rust owns the state, so Rust decides when the interface is stale. The usual implementation bumps a @State — see crate::state::set_state — which is the one thing SwiftUI does track, and re-runs the body against whatever Rust now holds. Without this, editing a Slider moves the thumb and updates the Rust value while a Text showing that value stays as it was.

The first registration wins; later calls are ignored.