Struct freya_native_core::real_dom::RealDom

source ·
pub struct RealDom<V: FromAnyValue + Send + Sync = ()> { /* private fields */ }
Expand description

A Dom that can sync with the VirtualDom mutations intended for use in lazy renderers. The render state passes from parent to children and or accumulates state from children to parents. To get started:

  1. Implement crate::passes::State for each part of your state that you want to compute incrementally
  2. Create a RealDom RealDom::new, passing in each state you created
  3. Update the state of the RealDom by adding and modifying nodes
  4. Call RealDom::update_state to update the state of incrementally computed values on each node

§Custom attribute values

To allow custom values to be passed into attributes implement FromAnyValue on a type that can represent your custom value and specify the V generic to be that type. If you have many different custom values, it can be useful to use a enum type to represent the variants.

Implementations§

source§

impl<V: FromAnyValue + Send + Sync> RealDom<V>

source

pub fn new(tracked_states: impl Into<Box<[TypeErasedState<V>]>>) -> RealDom<V>

Create a new RealDom with the given states that will be inserted and updated when needed

source

pub fn tree_ref(&self) -> TreeRefView<'_>

Get a reference to the tree.

source

pub fn tree_mut(&self) -> TreeMutView<'_>

Get a mutable reference to the tree.

source

pub fn create_node(&mut self, node: impl Into<NodeType<V>>) -> NodeMut<'_, V>

Create a new node of the given type in the dom and return a mutable reference to it.

source

pub fn is_node_listening(&self, node_id: &NodeId, event: &EventName) -> bool

source

pub fn get_listeners(&self, event: &EventName) -> Vec<NodeRef<'_, V>>

source

pub fn root_id(&self) -> NodeId

Returns the id of the root node.

source

pub fn contains(&self, id: NodeId) -> bool

Check if a node exists in the dom.

source

pub fn get(&self, id: NodeId) -> Option<NodeRef<'_, V>>

Get a reference to a node.

source

pub fn get_mut(&mut self, id: NodeId) -> Option<NodeMut<'_, V>>

Get a mutable reference to a node.

source

pub fn update_state( &mut self, ctx: SendAnyMap ) -> (FxDashSet<NodeId>, FxHashMap<NodeId, NodeMask>)

Update the state of the dom, after appling some mutations. This will keep the nodes in the dom up to date with their VNode counterparts.

source

pub fn traverse_depth_first_advanced( &self, f: impl FnMut(NodeRef<'_, V>) -> bool )

Traverses the dom in a depth first manner, calling the provided function on each node only when the parent function returns true. This is useful to not traverse through text nodes for instance.

source

pub fn traverse_depth_first(&self, f: impl FnMut(NodeRef<'_, V>))

Traverses the dom in a depth first manner, calling the provided function on each node.

source

pub fn raw_world(&self) -> &World

Returns a reference to the underlying world. Any changes made to the world will not update the reactive system.

source

pub fn raw_world_mut(&mut self) -> &mut World

Returns a mutable reference to the underlying world. Any changes made to the world will not update the reactive system.

Auto Trait Implementations§

§

impl<V = ()> !Freeze for RealDom<V>

§

impl<V = ()> !RefUnwindSafe for RealDom<V>

§

impl<V> Send for RealDom<V>

§

impl<V> Sync for RealDom<V>

§

impl<V> Unpin for RealDom<V>
where V: Unpin,

§

impl<V = ()> !UnwindSafe for RealDom<V>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<Ret> SpawnIfAsync<(), Ret> for Ret

§

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

§

fn super_from(input: T) -> O

Convert from a type to another type.
§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

§

fn super_into(self) -> O

Convert from a type to another type.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more