Browse Source

chore: use pending instead of async

Jonathan Kelley 2 years ago
parent
commit
3d69d3ea92

+ 1 - 1
packages/core/src/create.rs

@@ -342,7 +342,7 @@ impl<'b> VirtualDom {
         match unsafe { self.run_scope(scope).extend_lifetime_ref() } {
             Ready(t) => self.mount_component(scope, template, t, idx),
             Aborted(t) => self.mount_aborted(template, t),
-            Async(_) => self.mount_async(template, idx, scope),
+            Pending(_) => self.mount_async(template, idx, scope),
         }
     }
 

+ 6 - 6
packages/core/src/diff.rs

@@ -30,7 +30,7 @@ impl<'b> VirtualDom {
                 .try_load_node()
                 .expect("Call rebuild before diffing");
 
-            use RenderReturn::{Aborted, Async, Ready};
+            use RenderReturn::{Aborted, Pending, Ready};
 
             match (old, new) {
                 // Normal pathway
@@ -43,16 +43,16 @@ impl<'b> VirtualDom {
                 (Aborted(l), Aborted(r)) => r.id.set(l.id.get()),
 
                 // 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
                 // We should also clear the error now
                 (Aborted(l), Ready(r)) => self.replace_placeholder(l, [r]),
 
-                (Aborted(_), Async(_)) => todo!("async should not resolve here"),
-                (Async(_), Ready(_)) => todo!("async should not resolve here"),
-                (Async(_), Aborted(_)) => todo!("async should not resolve here"),
-                (Async(_), Async(_)) => {
+                (Aborted(_), Pending(_)) => todo!("async should not resolve here"),
+                (Pending(_), Ready(_)) => todo!("async should not resolve here"),
+                (Pending(_), Aborted(_)) => todo!("async should not resolve here"),
+                (Pending(_), Pending(_)) => {
                     // All suspense should resolve before we diff it again
                     panic!("Should not roll from suspense to suspense.");
                 }

+ 2 - 2
packages/core/src/nodes.rs

@@ -30,7 +30,7 @@ pub enum RenderReturn<'a> {
     Aborted(VPlaceholder),
 
     /// 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> {
@@ -443,7 +443,7 @@ where
 {
     fn into_return(self, cx: &'a ScopeState) -> RenderReturn<'a> {
         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
packages/core/src/scope_arena.rs

@@ -84,7 +84,7 @@ impl VirtualDom {
         };
 
         // 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 entry = leaves.vacant_entry();

+ 1 - 1
packages/core/src/virtual_dom.rs

@@ -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
             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()