Skip to main content

track

Function track 

Source
pub fn track(read: impl FnMut(), on_change: impl Fn() + Send + Sync + 'static)
Expand description

Run read, remembering every observable property it touches, and call on_change once when any of them next changes.

withObservationTracking, which is what SwiftUI itself uses to decide that a view needs rebuilding. Once: the handler fires for the first change and then the subscription is over, which is Swift’s behaviour too — a view re-reads on the next render and so re-subscribes.