Struct dioxus_core::prelude::NodeFactory
source · [−]pub struct NodeFactory<'a> { /* private fields */ }
Expand description
This struct provides an ergonomic API to quickly build VNodes.
NodeFactory is used to build VNodes in the component’s memory space. This struct adds metadata to the final VNode about listeners, attributes, and children
Implementations
sourceimpl<'a> NodeFactory<'a>
impl<'a> NodeFactory<'a>
sourcepub fn new(scope: &'a ScopeState) -> NodeFactory<'a>
pub fn new(scope: &'a ScopeState) -> NodeFactory<'a>
Create a new NodeFactory
from a Scope
or ScopeState
sourcepub fn static_text(&self, text: &'static str) -> VNode<'a>
pub fn static_text(&self, text: &'static str) -> VNode<'a>
Directly pass in text blocks without the need to use the format_args macro.
sourcepub fn raw_text(&self, args: Arguments<'_>) -> (&'a str, bool)
pub fn raw_text(&self, args: Arguments<'_>) -> (&'a str, bool)
Parses a lazy text Arguments and returns a string and a flag indicating if the text is ’static
Text that’s static may be pointer compared, making it cheaper to diff
sourcepub fn text(&self, args: Arguments<'_>) -> VNode<'a>
pub fn text(&self, args: Arguments<'_>) -> VNode<'a>
Create some text that’s allocated along with the other vnodes
sourcepub fn element(
&self,
el: impl DioxusElement,
listeners: &'a [Listener<'a>],
attributes: &'a [Attribute<'a>],
children: &'a [VNode<'a>],
key: Option<Arguments<'_>>
) -> VNode<'a>
pub fn element(
&self,
el: impl DioxusElement,
listeners: &'a [Listener<'a>],
attributes: &'a [Attribute<'a>],
children: &'a [VNode<'a>],
key: Option<Arguments<'_>>
) -> VNode<'a>
Create a new [VNode::VElement
]
sourcepub fn raw_element(
&self,
tag_name: &'static str,
namespace: Option<&'static str>,
listeners: &'a [Listener<'a>],
attributes: &'a [Attribute<'a>],
children: &'a [VNode<'a>],
key: Option<Arguments<'_>>
) -> VNode<'a>
pub fn raw_element(
&self,
tag_name: &'static str,
namespace: Option<&'static str>,
listeners: &'a [Listener<'a>],
attributes: &'a [Attribute<'a>],
children: &'a [VNode<'a>],
key: Option<Arguments<'_>>
) -> VNode<'a>
Create a new [VNode::VElement
] without the trait bound
IE pass in “div” instead of div
sourcepub fn attr(
&self,
name: &'static str,
val: Arguments<'_>,
namespace: Option<&'static str>,
is_volatile: bool
) -> Attribute<'a>
pub fn attr(
&self,
name: &'static str,
val: Arguments<'_>,
namespace: Option<&'static str>,
is_volatile: bool
) -> Attribute<'a>
Create a new Attribute
sourcepub fn component<P>(
&self,
component: fn(_: Scope<'a, P>) -> Element<'_>,
props: P,
key: Option<Arguments<'_>>,
fn_name: &'static str
) -> VNode<'a> where
P: Properties + 'a,
pub fn component<P>(
&self,
component: fn(_: Scope<'a, P>) -> Element<'_>,
props: P,
key: Option<Arguments<'_>>,
fn_name: &'static str
) -> VNode<'a> where
P: Properties + 'a,
Create a new [VNode::VComponent
]
sourcepub fn listener(
self,
event: &'static str,
callback: &'a RefCell<Option<BumpBox<'a, dyn FnMut(AnyEvent) + 'a>>>
) -> Listener<'a>
pub fn listener(
self,
event: &'static str,
callback: &'a RefCell<Option<BumpBox<'a, dyn FnMut(AnyEvent) + 'a>>>
) -> Listener<'a>
Create a new Listener
sourcepub fn fragment_root<'b, 'c>(
self,
node_iter: impl IntoIterator<Item = impl IntoVNode<'a> + 'c> + 'b
) -> VNode<'a>
pub fn fragment_root<'b, 'c>(
self,
node_iter: impl IntoIterator<Item = impl IntoVNode<'a> + 'c> + 'b
) -> VNode<'a>
Create a new [VNode::VFragment
] from a root of the rsx! call
sourcepub fn fragment_from_iter<'b, 'c>(
self,
node_iter: impl IntoIterator<Item = impl IntoVNode<'a> + 'c> + 'b
) -> VNode<'a>
pub fn fragment_from_iter<'b, 'c>(
self,
node_iter: impl IntoIterator<Item = impl IntoVNode<'a> + 'c> + 'b
) -> VNode<'a>
Create a new [VNode::VFragment
] from any iterator
sourcepub fn create_children(
self,
node_iter: impl IntoIterator<Item = impl IntoVNode<'a>>
) -> Element<'a>
pub fn create_children(
self,
node_iter: impl IntoIterator<Item = impl IntoVNode<'a>>
) -> Element<'a>
Create a new VNode
from any iterator of children
sourcepub fn event_handler<T>(self, f: impl FnMut(T) + 'a) -> EventHandler<'a, T>
pub fn event_handler<T>(self, f: impl FnMut(T) + 'a) -> EventHandler<'a, T>
Create a new EventHandler
from an FnMut
Trait Implementations
sourceimpl<'a> Clone for NodeFactory<'a>
impl<'a> Clone for NodeFactory<'a>
sourcefn clone(&self) -> NodeFactory<'a>
fn clone(&self) -> NodeFactory<'a>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for NodeFactory<'_>
impl Debug for NodeFactory<'_>
impl<'a> Copy for NodeFactory<'a>
Auto Trait Implementations
impl<'a> !RefUnwindSafe for NodeFactory<'a>
impl<'a> !Send for NodeFactory<'a>
impl<'a> !Sync for NodeFactory<'a>
impl<'a> Unpin for NodeFactory<'a>
impl<'a> !UnwindSafe for NodeFactory<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more