Struct percy_dom::PercyDom

source ·
pub struct PercyDom {
    pub events: VirtualEvents,
    /* private fields */
}
Expand description

Used for keeping a real DOM node up to date based on the current VirtualNode and a new incoming VirtualNode that represents our latest DOM state.

Also powers event delegation.

Fields§

§events: VirtualEvents

The closures that are currently attached to elements in the page. We keep these around so that they don’t get dropped, (and thus stop working).

Implementations§

source§

impl PercyDom

source

pub fn new(current_vdom: VirtualNode) -> PercyDom

Create a new PercyDom.

A root Node will be created but not added to your DOM.

source

pub fn new_append_to_mount( current_vdom: VirtualNode, mount: &Element ) -> PercyDom

Create a new PercyDom.

A root Node will be created and append (as a child) to your passed in mount element.

source

pub fn new_replace_mount(current_vdom: VirtualNode, mount: Element) -> PercyDom

Create a new PercyDom.

A root Node will be created and it will replace your passed in mount element.

source

pub fn update(&mut self, new_vdom: VirtualNode)

Diff the current virtual dom with the new virtual dom that is being passed in.

Then use that diff to patch the real DOM in the user’s browser so that they are seeing the latest state of the application.

source

pub fn root_node(&self) -> Node

Return the root node of your application, the highest ancestor of all other nodes in your real DOM tree.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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.

source§

impl<T, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.