Skip to main content

timeline

Function timeline 

Source
pub fn timeline(builder: impl Fn() -> ViewHandle + 'static) -> ViewHandle
Expand description

TimelineView(.animation) { … } — rebuild the content on SwiftUI’s clock.

This is the answer to triggering. Assigning a hosting view’s rootView replaces the tree, so SwiftUI has nothing to interpolate and no reason to treat a change as a change — which is why an external mutation never animated. A TimelineView inverts it: SwiftUI calls back on every display frame, so the builder re-reads Rust state and the interface follows it with no set_root at all.

ⓘ
let state = BoundState::new(0.0);
let ui = timeline({
    let s = state.clone();
    move || views::offset(&views::circle(), s.get(), 0.0)
});
// mutating `state` from Rust now shows up by itself

The builder is leaked: SwiftUI keeps calling it for as long as the view lives.