Struct sauron::dom::DomUpdater [−][src]
pub struct DomUpdater<MSG> { pub current_vdom: Node<&'static str, &'static str, &'static str, AttributeValue, Callback<Event, MSG>>, pub root_node: Node, pub active_closures: HashMap<u32, Vec<(&'static str, Closure<dyn FnMut(Event) + 'static>), Global>, RandomState>, pub focused_node: Option<Node>, }
Expand description
Used for keeping a real DOM node up to date based on the current Node and a new incoming Node that represents our latest DOM state.
Fields
current_vdom: Node<&'static str, &'static str, &'static str, AttributeValue, Callback<Event, MSG>>
the current vdom representation
root_node: Node
the equivalent actual DOM element where the App is mounted into
active_closures: HashMap<u32, Vec<(&'static str, Closure<dyn FnMut(Event) + 'static>), Global>, RandomState>
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);
focused_node: Option<Node>
after mounting or update dispatch call, the element will be focused
Implementations
Creates and instance of this DOM updater, but doesn’t mount the current_vdom to the DOM just yet.
count the total active closures regardless of which element it attached to.
pub fn append_to_mount<DSP>(&mut self, program: &DSP) where
DSP: Dispatch<MSG> + Clone + 'static,
pub fn append_to_mount<DSP>(&mut self, program: &DSP) where
DSP: Dispatch<MSG> + Clone + 'static,
Mount the current_vdom appending to the actual browser DOM specified in the root_node This also gets the closures that was created when mounting the vdom to their actual DOM counterparts.
pub fn replace_mount<DSP>(&mut self, program: &DSP) where
DSP: Dispatch<MSG> + Clone + 'static,
pub fn replace_mount<DSP>(&mut self, program: &DSP) where
DSP: Dispatch<MSG> + Clone + 'static,
Mount the current_vdom replacing the actual browser DOM specified in the root_node This also gets the closures that was created when mounting the vdom to their actual DOM counterparts.
pub fn new_append_to_mount<DSP>(
program: &DSP,
current_vdom: Node<&'static str, &'static str, &'static str, AttributeValue, Callback<Event, MSG>>,
mount: &Element
) -> DomUpdater<MSG> where
DSP: Dispatch<MSG> + Clone + 'static,
pub fn new_append_to_mount<DSP>(
program: &DSP,
current_vdom: Node<&'static str, &'static str, &'static str, AttributeValue, Callback<Event, MSG>>,
mount: &Element
) -> DomUpdater<MSG> where
DSP: Dispatch<MSG> + Clone + 'static,
Create a new DomUpdater
.
A root Node
will be created and appended (as a child) to your passed
in mount element.
pub fn new_replace_mount<DSP>(
program: &DSP,
current_vdom: Node<&'static str, &'static str, &'static str, AttributeValue, Callback<Event, MSG>>,
mount: Element
) -> DomUpdater<MSG> where
DSP: Dispatch<MSG> + Clone + 'static,
pub fn new_replace_mount<DSP>(
program: &DSP,
current_vdom: Node<&'static str, &'static str, &'static str, AttributeValue, Callback<Event, MSG>>,
mount: Element
) -> DomUpdater<MSG> where
DSP: Dispatch<MSG> + Clone + 'static,
Create a new DomUpdater
.
A root Node
will be created and it will replace your passed in mount
element.
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.
Apply patches to the dom updater Warning: only used this for debuggin purposes
pub fn map_msg<F, MSG2>(self, func: F) -> DomUpdater<MSG2> where
MSG2: 'static,
F: Fn(MSG) -> MSG2 + 'static,
pub fn map_msg<F, MSG2>(self, func: F) -> DomUpdater<MSG2> where
MSG2: 'static,
F: Fn(MSG) -> MSG2 + 'static,
map this DomUpdater such that the Node