chore: use pending instead of async

This commit is contained in:
Jonathan Kelley committed 2022-12-25 01:43:22 -05:00
1 parent 9b0244ee5c
commit 3d69d3ea92
5 files changed
+11 -11

No files matched your search

+1 -1
View File
@@ -342,7 +342,7 @@ impl<'b> VirtualDom {
match unsafe { self.run_scope(scope).extend_lifetime_ref() } { match unsafe { self.run_scope(scope).extend_lifetime_ref() } {
Ready(t) => self.mount_component(scope, template, t, idx), Ready(t) => self.mount_component(scope, template, t, idx),
Aborted(t) => self.mount_aborted(template, t), Aborted(t) => self.mount_aborted(template, t),
Async(_) => self.mount_async(template, idx, scope), Pending(_) => self.mount_async(template, idx, scope),
} }
} }
+6 -6
View File
@@ -30,7 +30,7 @@ impl<'b> VirtualDom {
.try_load_node() .try_load_node()
.expect("Call rebuild before diffing"); .expect("Call rebuild before diffing");
use RenderReturn::{Aborted, Async, Ready}; use RenderReturn::{Aborted, Pending, Ready};
match (old, new) { match (old, new) {
// Normal pathway // Normal pathway
@@ -43,16 +43,16 @@ impl<'b> VirtualDom {
(Aborted(l), Aborted(r)) => r.id.set(l.id.get()), (Aborted(l), Aborted(r)) => r.id.set(l.id.get()),
// Becomes async, do nothing while we ait // Becomes async, do nothing while we ait
(Ready(_nodes), Async(_fut)) => self.diff_ok_to_async(_nodes, scope), (Ready(_nodes), Pending(_fut)) => self.diff_ok_to_async(_nodes, scope),
// Placeholder becomes something // Placeholder becomes something
// We should also clear the error now // We should also clear the error now
(Aborted(l), Ready(r)) => self.replace_placeholder(l, [r]), (Aborted(l), Ready(r)) => self.replace_placeholder(l, [r]),
(Aborted(_), Async(_)) => todo!("async should not resolve here"), (Aborted(_), Pending(_)) => todo!("async should not resolve here"),
(Async(_), Ready(_)) => todo!("async should not resolve here"), (Pending(_), Ready(_)) => todo!("async should not resolve here"),
(Async(_), Aborted(_)) => todo!("async should not resolve here"), (Pending(_), Aborted(_)) => todo!("async should not resolve here"),
(Async(_), Async(_)) => { (Pending(_), Pending(_)) => {
// All suspense should resolve before we diff it again // All suspense should resolve before we diff it again
panic!("Should not roll from suspense to suspense."); panic!("Should not roll from suspense to suspense.");
} }
+2 -2
View File
@@ -30,7 +30,7 @@ pub enum RenderReturn<'a> {
Aborted(VPlaceholder), Aborted(VPlaceholder),
/// An ongoing future that will resolve to a [`Element`] /// An ongoing future that will resolve to a [`Element`]
Async(BumpBox<'a, dyn Future<Output = Element<'a>> + 'a>), Pending(BumpBox<'a, dyn Future<Output = Element<'a>> + 'a>),
} }
impl<'a> Default for RenderReturn<'a> { impl<'a> Default for RenderReturn<'a> {
@@ -443,7 +443,7 @@ where
{ {
fn into_return(self, cx: &'a ScopeState) -> RenderReturn<'a> { fn into_return(self, cx: &'a ScopeState) -> RenderReturn<'a> {
let f: &mut dyn Future<Output = Element<'a>> = cx.bump().alloc(self); let f: &mut dyn Future<Output = Element<'a>> = cx.bump().alloc(self);
RenderReturn::Async(unsafe { BumpBox::from_raw(f) }) RenderReturn::Pending(unsafe { BumpBox::from_raw(f) })
} }
} }
+1 -1
View File
@@ -84,7 +84,7 @@ impl VirtualDom {
}; };
// immediately resolve futures that can be resolved // immediately resolve futures that can be resolved
if let RenderReturn::Async(task) = &mut new_nodes { if let RenderReturn::Pending(task) = &mut new_nodes {
let mut leaves = self.scheduler.leaves.borrow_mut(); let mut leaves = self.scheduler.leaves.borrow_mut();
let entry = leaves.vacant_entry(); let entry = leaves.vacant_entry();
+1 -1
View File
@@ -486,7 +486,7 @@ impl VirtualDom {
} }
// If an error occurs, we should try to render the default error component and context where the error occured // If an error occurs, we should try to render the default error component and context where the error occured
RenderReturn::Aborted(_placeholder) => panic!("Cannot catch errors during rebuild"), RenderReturn::Aborted(_placeholder) => panic!("Cannot catch errors during rebuild"),
RenderReturn::Async(_) => unreachable!("Root scope cannot be an async component"), RenderReturn::Pending(_) => unreachable!("Root scope cannot be an async component"),
} }
self.finalize() self.finalize()