Chore: comments
This commit is contained in:
1 parent
bf6a149c3b
commit
18a7a1f9c4
2 files changed
+13
-9
No files matched your search
@@ -78,7 +78,9 @@ impl VirtualDom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//// Performs a *full* rebuild of the virtual dom, returning every edit required to generate the actual dom
|
/// Performs a *full* rebuild of the virtual dom, returning every edit required to generate the actual dom.
|
||||||
|
///
|
||||||
|
///
|
||||||
pub fn rebuild(&mut self) -> Result<EditList<'_>> {
|
pub fn rebuild(&mut self) -> Result<EditList<'_>> {
|
||||||
// Reset and then build a new diff machine
|
// Reset and then build a new diff machine
|
||||||
// The previous edit list cannot be around while &mut is held
|
// The previous edit list cannot be around while &mut is held
|
||||||
|
|||||||
+10
-8
@@ -56,8 +56,8 @@ impl WebsysRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new text renderer from an existing Virtual DOM.
|
/// Create a new text renderer from an existing Virtual DOM.
|
||||||
/// This will progress the existing VDom's events to completion.
|
|
||||||
pub fn from_vdom(dom: VirtualDom) -> Self {
|
pub fn from_vdom(dom: VirtualDom) -> Self {
|
||||||
|
// todo: initialize the event registry properly
|
||||||
Self {
|
Self {
|
||||||
internal_dom: dom,
|
internal_dom: dom,
|
||||||
_event_map: FxHashMap::default(),
|
_event_map: FxHashMap::default(),
|
||||||
@@ -67,15 +67,17 @@ impl WebsysRenderer {
|
|||||||
pub async fn run(&mut self) -> dioxus_core::error::Result<()> {
|
pub async fn run(&mut self) -> dioxus_core::error::Result<()> {
|
||||||
let (sender, mut receiver) = mpsc::unbounded::<EventTrigger>();
|
let (sender, mut receiver) = mpsc::unbounded::<EventTrigger>();
|
||||||
|
|
||||||
let body = prepare_websys_dom();
|
let body_element = prepare_websys_dom();
|
||||||
let mut patch_machine = interpreter::PatchMachine::new(body.clone());
|
let mut patch_machine = interpreter::PatchMachine::new(body_element.clone());
|
||||||
let root_node = body.first_child().unwrap();
|
let root_node = body_element.first_child().unwrap();
|
||||||
patch_machine.stack.push(root_node);
|
patch_machine.stack.push(root_node);
|
||||||
|
|
||||||
|
// todo: initialize the event registry properly on the root element
|
||||||
|
|
||||||
self.internal_dom
|
self.internal_dom
|
||||||
.rebuild()?
|
.rebuild()?
|
||||||
.into_iter()
|
.iter()
|
||||||
.for_each(|edit| patch_machine.handle_edit(&edit));
|
.for_each(|edit| patch_machine.handle_edit(edit));
|
||||||
|
|
||||||
// Event loop waits for the receiver to finish up
|
// Event loop waits for the receiver to finish up
|
||||||
// TODO! Connect the sender to the virtual dom's suspense system
|
// TODO! Connect the sender to the virtual dom's suspense system
|
||||||
@@ -83,9 +85,9 @@ impl WebsysRenderer {
|
|||||||
while let Some(event) = receiver.next().await {
|
while let Some(event) = receiver.next().await {
|
||||||
self.internal_dom
|
self.internal_dom
|
||||||
.progress_with_event(event)?
|
.progress_with_event(event)?
|
||||||
.into_iter()
|
.iter()
|
||||||
.for_each(|edit| {
|
.for_each(|edit| {
|
||||||
patch_machine.handle_edit(&edit);
|
patch_machine.handle_edit(edit);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user