Struct sycamore_core::view::View
source · [−]pub struct View<G: GenericNode> { /* private fields */ }
Expand description
Represents an UI view. Usually constructed using the view!
macro or using the builder API.
Example
let my_view: View<G> = view! { cx,
div {
p { "A view." }
}
};
Implementations
sourceimpl<G: GenericNode> View<G>
impl<G: GenericNode> View<G>
sourcepub fn new_dyn_scoped<'a>(
cx: Scope<'a>,
f: impl FnMut(BoundedScope<'_, 'a>) -> View<G> + 'a
) -> Self
pub fn new_dyn_scoped<'a>(
cx: Scope<'a>,
f: impl FnMut(BoundedScope<'_, 'a>) -> View<G> + 'a
) -> Self
sourcepub fn new_fragment(fragment: Vec<View<G>>) -> Self
pub fn new_fragment(fragment: Vec<View<G>>) -> Self
sourcepub fn empty() -> Self
pub fn empty() -> Self
Create a new View
with a blank marker node
Note that this is different from an empty view fragment. Instead, this is a single marker (dummy) node.
sourcepub fn as_node(&self) -> Option<&G>
pub fn as_node(&self) -> Option<&G>
Try to cast to a GenericNode
, or None
if wrong type.
sourcepub fn as_fragment(&self) -> Option<&[View<G>]>
pub fn as_fragment(&self) -> Option<&[View<G>]>
Try to cast to a slice representing the view fragment, or None
if wrong type.
sourcepub fn as_dyn(&self) -> Option<&RcSignal<View<G>>>
pub fn as_dyn(&self) -> Option<&RcSignal<View<G>>>
Try to cast to the underlying RcSignal
for a dynamic view, or None
if wrong type.
sourcepub fn is_node(&self) -> bool
pub fn is_node(&self) -> bool
Returns true
if the view is a single node. Note that if the view is a fragment containing
only a single child node, this will still return false
.
To check whether the View
only contains a single node, use .flatten().len() == 1
instead.
sourcepub fn is_fragment(&self) -> bool
pub fn is_fragment(&self) -> bool
Returns true
if the view is a view fragment.
Trait Implementations
sourceimpl<G: Clone + GenericNode> Clone for View<G>
impl<G: Clone + GenericNode> Clone for View<G>
sourceimpl<G: GenericNode> Debug for View<G>
impl<G: GenericNode> Debug for View<G>
sourceimpl<G: GenericNode> Default for View<G>
impl<G: GenericNode> Default for View<G>
sourceimpl<'a, G: GenericNode> From<View<G>> for Children<'a, G>
impl<'a, G: GenericNode> From<View<G>> for Children<'a, G>
sourceimpl<G: GenericNode> IntoView<G> for &View<G>
impl<G: GenericNode> IntoView<G> for &View<G>
Auto Trait Implementations
impl<G> !RefUnwindSafe for View<G>
impl<G> !Send for View<G>
impl<G> !Sync for View<G>
impl<G> Unpin for View<G>where
G: Unpin,
impl<G> !UnwindSafe for View<G>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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