pub struct Composer { /* private fields */ }Implementations§
Source§impl Composer
impl Composer
pub fn new( slots: Rc<SlotsHost>, applier: Rc<dyn ApplierHost>, runtime: RuntimeHandle, observer: SnapshotStateObserver, root: Option<NodeId>, ) -> Self
Sourcepub fn register_virtual_node(
&self,
node_id: NodeId,
node: Box<dyn Node>,
) -> Result<(), NodeError>
pub fn register_virtual_node( &self, node_id: NodeId, node: Box<dyn Node>, ) -> Result<(), NodeError>
Registers a virtual node in the Applier.
This is used by SubcomposeLayoutNode to register virtual container nodes so that subsequent insert_child commands can find them and attach children. Without this, virtual nodes would only exist in SubcomposeLayoutNodeInner.virtual_nodes and applier.get_mut(virtual_node_id) would fail, breaking child attachment.
Sourcepub fn node_has_no_parent(&self, node_id: NodeId) -> bool
pub fn node_has_no_parent(&self, node_id: NodeId) -> bool
Checks if a node has no parent (is a root node). Used by SubcomposeMeasureScope to filter subcompose results.
Sourcepub fn get_node_children(&self, node_id: NodeId) -> Vec<NodeId> ⓘ
pub fn get_node_children(&self, node_id: NodeId) -> Vec<NodeId> ⓘ
Gets the children of a node from the Applier.
This is used by SubcomposeLayoutNode to get children of virtual nodes directly from the Applier, where insert_child commands have been applied.
Sourcepub fn clear_node_children(&self, node_id: NodeId)
pub fn clear_node_children(&self, node_id: NodeId)
Clears all children of a node in the Applier.
This is used by SubcomposeLayoutNode when reusing a virtual node for different content. Without clearing, old children remain attached, causing duplicate/interleaved items in lazy lists after scrolling.
pub fn install<R>(&self, f: impl FnOnce(&Composer) -> R) -> R
pub fn with_group<R>(&self, key: Key, f: impl FnOnce(&Composer) -> R) -> R
pub fn cranpose_with_reuse<R>( &self, key: Key, options: RecomposeOptions, f: impl FnOnce(&Composer) -> R, ) -> R
pub fn with_key<K: Hash, R>(&self, key: &K, f: impl FnOnce(&Composer) -> R) -> R
pub fn remember<T: 'static>(&self, init: impl FnOnce() -> T) -> Owned<T>
pub fn use_value_slot<T: 'static>(&self, init: impl FnOnce() -> T) -> usize
pub fn with_slot_value<T: 'static, R>( &self, idx: usize, f: impl FnOnce(&T) -> R, ) -> R
pub fn with_slot_value_mut<T: 'static, R>( &self, idx: usize, f: impl FnOnce(&mut T) -> R, ) -> R
pub fn write_slot_value<T: 'static>(&self, idx: usize, value: T)
pub fn mutable_state_of<T: Clone + 'static>( &self, initial: T, ) -> MutableState<T>
pub fn mutable_state_list_of<T, I>(&self, values: I) -> SnapshotStateList<T>where
T: Clone + 'static,
I: IntoIterator<Item = T>,
pub fn mutable_state_map_of<K, V, I>(&self, pairs: I) -> SnapshotStateMap<K, V>
pub fn read_composition_local<T: Clone + 'static>( &self, local: &CompositionLocal<T>, ) -> T
pub fn read_static_composition_local<T: Clone + 'static>( &self, local: &StaticCompositionLocal<T>, ) -> T
pub fn current_recranpose_scope(&self) -> Option<RecomposeScope>
pub fn phase(&self) -> Phase
pub fn enter_phase(&self, phase: Phase)
pub fn subcompose_measurement<R>( &self, state: &mut SubcomposeState, slot_id: SlotId, content: impl FnOnce(&Composer) -> R, ) -> (R, Vec<NodeId>)
pub fn subcompose_in<R>( &self, slots: &Rc<SlotsHost>, root: Option<NodeId>, f: impl FnOnce(&Composer) -> R, ) -> Result<R, NodeError>
Sourcepub fn subcompose_slot<R>(
&self,
slots: &Rc<SlotsHost>,
root: Option<NodeId>,
f: impl FnOnce(&Composer) -> R,
) -> Result<R, NodeError>
pub fn subcompose_slot<R>( &self, slots: &Rc<SlotsHost>, root: Option<NodeId>, f: impl FnOnce(&Composer) -> R, ) -> Result<R, NodeError>
Subcomposes content using an isolated SlotsHost without resetting it.
Unlike subcompose_in, this preserves existing slot state across calls,
allowing efficient reuse during measurement passes. This is critical for
lazy lists where items need stable slot positions.
pub fn skip_current_group(&self)
pub fn runtime_handle(&self) -> RuntimeHandle
pub fn set_recranpose_callback<F>(&self, callback: F)
pub fn with_composition_locals<R>( &self, provided: Vec<ProvidedValue>, f: impl FnOnce(&Composer) -> R, ) -> R
pub fn use_state<T: Clone + 'static>( &self, init: impl FnOnce() -> T, ) -> MutableState<T>
pub fn emit_node<N: Node + 'static>(&self, init: impl FnOnce() -> N) -> NodeId
pub fn with_node_mut<N: Node + 'static, R>( &self, id: NodeId, f: impl FnOnce(&mut N) -> R, ) -> Result<R, NodeError>
pub fn push_parent(&self, id: NodeId)
pub fn pop_parent(&self)
pub fn take_commands( &self, ) -> Vec<Box<dyn FnMut(&mut dyn Applier) -> Result<(), NodeError> + 'static>>
Sourcepub fn apply_pending_commands(&self) -> Result<(), NodeError>
pub fn apply_pending_commands(&self) -> Result<(), NodeError>
Applies any pending applier commands and runtime updates.
This is useful during measure-time subcomposition to ensure newly created nodes are available for measurement before the full composition is committed.