Skip to main content

create_dynamic_node_with_context

Function create_dynamic_node_with_context 

Source
pub fn create_dynamic_node_with_context<F>(render_fn: F) -> VirtualNode
where F: FnMut(&mut HookContext) -> VirtualNode + 'static,
Expand description

Constructs a VirtualNode::Dynamic for match expressions where arm hook isolation is required. The render closure receives a &mut HookContext so it can call set_arm_changed before each arm body.

This function replaces the inline HookContext + DynamicNode setup that was previously generated for match nodes, where the hook context had to be accessible inside the render closure for arm switching.

§Arguments

  • FnMut(&mut HookContext) -> VirtualNode + 'static - The render closure that receives a mutable reference to the hook context. The closure is responsible for calling set_arm_changed before each match arm.

§Returns

  • VirtualNode - A VirtualNode::Dynamic wrapping the render closure with a fresh HookContext.