wip: basic support for scheduled rendering
This commit is contained in:
1 parent
80e6c25698
commit
c52af221f7
8 files changed
+93
-80
No files matched your search
@@ -66,6 +66,11 @@ impl RealDomNode {
|
||||
let key: DefaultKey = data.into();
|
||||
Self(key)
|
||||
}
|
||||
pub fn from_u64(id: u64) -> Self {
|
||||
let data = KeyData::from_ffi(id);
|
||||
let key: DefaultKey = data.into();
|
||||
Self(key)
|
||||
}
|
||||
pub fn empty_cell() -> Cell<Self> {
|
||||
Cell::new(Self::empty())
|
||||
}
|
||||
@@ -102,7 +107,8 @@ impl<'a> RealDom<'a> for DebugDom {
|
||||
async fn launch_demo(app: FC<()>) {
|
||||
let mut dom = VirtualDom::new(app);
|
||||
let mut real_dom = DebugDom::new();
|
||||
dom.rebuild(&mut real_dom).unwrap();
|
||||
let mut edits = Vec::new();
|
||||
dom.rebuild(&mut real_dom, &mut edits).unwrap();
|
||||
|
||||
while let Some(evt) = dom.tasks.next().await {
|
||||
//
|
||||
|
||||
@@ -191,7 +191,8 @@ impl VirtualDom {
|
||||
/// SSR takes advantage of this by using Dioxus itself as the source of truth, and rendering from the tree directly.
|
||||
pub fn rebuild_in_place(&mut self) -> Result<()> {
|
||||
let mut realdom = DebugDom::new();
|
||||
self.rebuild(&mut realdom)
|
||||
let mut edits = Vec::new();
|
||||
self.rebuild(&mut realdom, &mut edits)
|
||||
}
|
||||
|
||||
/// Performs a *full* rebuild of the virtual dom, returning every edit required to generate the actual dom rom scratch
|
||||
@@ -199,10 +200,13 @@ impl VirtualDom {
|
||||
/// Currently this doesn't do what we want it to do
|
||||
///
|
||||
/// The diff machine expects the RealDom's stack to be the root of the application
|
||||
pub fn rebuild<'s, Dom: RealDom<'s>>(&'s mut self, realdom: &mut Dom) -> Result<()> {
|
||||
let mut edits = Vec::new();
|
||||
pub fn rebuild<'s, Dom: RealDom<'s>>(
|
||||
&'s mut self,
|
||||
realdom: &mut Dom,
|
||||
edits: &mut Vec<DomEdit<'s>>,
|
||||
) -> Result<()> {
|
||||
let mut diff_machine = DiffMachine::new(
|
||||
&mut edits,
|
||||
edits,
|
||||
realdom,
|
||||
&self.components,
|
||||
self.base_scope,
|
||||
@@ -211,7 +215,6 @@ impl VirtualDom {
|
||||
);
|
||||
|
||||
let cur_component = self.components.try_get_mut(self.base_scope).unwrap();
|
||||
|
||||
cur_component.run_scope()?;
|
||||
|
||||
let meta = diff_machine.create(cur_component.next_frame());
|
||||
@@ -278,12 +281,12 @@ impl VirtualDom {
|
||||
pub async fn progress_with_event<'s, Dom: RealDom<'s>>(
|
||||
&'s mut self,
|
||||
realdom: &'_ mut Dom,
|
||||
edits: &mut Vec<DomEdit<'s>>,
|
||||
) -> Result<()> {
|
||||
let trigger = self.triggers.borrow_mut().pop().expect("failed");
|
||||
|
||||
let mut edits = Vec::new();
|
||||
let mut diff_machine = DiffMachine::new(
|
||||
&mut edits,
|
||||
edits,
|
||||
realdom,
|
||||
&self.components,
|
||||
trigger.originator,
|
||||
@@ -295,9 +298,9 @@ impl VirtualDom {
|
||||
VirtualEvent::OtherEvent => todo!(),
|
||||
|
||||
// Fiber events
|
||||
VirtualEvent::FiberEvent => {
|
||||
//
|
||||
}
|
||||
// VirtualEvent::FiberEvent => {
|
||||
// //
|
||||
// }
|
||||
|
||||
// This is the "meat" of our cooperative scheduler
|
||||
// As updates flow in, we re-evalute the event queue and decide if we should be switching the type of work
|
||||
|
||||
Reference in new issue
Block a user