pub struct Composition<A: Applier + 'static> { /* private fields */ }Implementations§
Source§impl<A: Applier + 'static> Composition<A>
impl<A: Applier + 'static> Composition<A>
pub fn new(applier: A) -> Self
pub fn with_runtime(applier: A, runtime: Runtime) -> Self
Sourcepub fn root_key(&self) -> Option<Key>
pub fn root_key(&self) -> Option<Key>
Returns the root group key captured from the most recent render() call,
or None before the first render.
pub fn set_retention_policy(&self, policy: RetentionPolicy)
pub fn take_root_render_request(&mut self) -> bool
pub fn request_root_render(&mut self)
pub fn render( &mut self, key: Key, content: impl FnMut(), ) -> Result<(), NodeError>
Sourcepub fn render_stable(
&mut self,
key: Key,
content: impl FnMut(),
) -> Result<(), NodeError>
pub fn render_stable( &mut self, key: Key, content: impl FnMut(), ) -> Result<(), NodeError>
Perform a root render and continue replaying any resulting root-render requests until the composition reaches a stable fixpoint.
Sourcepub fn reconcile(
&mut self,
key: Key,
content: impl FnMut(),
) -> Result<bool, NodeError>
pub fn reconcile( &mut self, key: Key, content: impl FnMut(), ) -> Result<bool, NodeError>
Process invalid scopes and any resulting root-render requests until the composition reaches a stable fixpoint for the supplied root content.
Sourcepub fn should_render(&self) -> bool
pub fn should_render(&self) -> bool
Returns true if composition needs to process invalid scopes (recompose).
This checks both:
has_updates(): composition scopes that were invalidated by state changesneeds_frame(): animation callbacks that may have pending work
Note: For scroll performance, ensure scroll state changes use Cell
Sourcepub fn should_recompose(&self) -> bool
pub fn should_recompose(&self) -> bool
Whether any composition scope is actually invalid, i.e. whether running the composable tree could produce a different result than last time.
Deliberately excludes Runtime::needs_frame, which [should_render]
includes. An armed frame callback means the runtime owes someone a
tick - a future to resume, a dispatcher to drain - and every app with a
game loop or a polling effect has one armed at all times. Re-running the
composition for it recomposes a tree that nothing invalidated. Callers
deciding “should I tick” want [should_render]; callers deciding
“should I recompose” want this.
It is only meaningful after the frame callbacks have been drained: a callback that writes state invalidates its readers as it runs, so the answer is a question about work already discovered, not work still to come.