implement suspense using simpler approach
This commit is contained in:
5 files changed
+27
-83
No files matched your search
@@ -85,6 +85,8 @@ impl VirtualDom {
|
||||
|
||||
if scope.suspended.get() {
|
||||
self.suspended_scopes.insert(scope.id);
|
||||
} else if !self.suspended_scopes.is_empty() {
|
||||
_ = self.suspended_scopes.remove(&scope.id);
|
||||
}
|
||||
|
||||
// rebind the lifetime now that its stored internally
|
||||
|
||||
@@ -655,7 +655,7 @@ impl<'src> ScopeState {
|
||||
}
|
||||
|
||||
/// Mark this component as suspended and then return None
|
||||
pub fn suspend(&self) -> Option<()> {
|
||||
pub fn suspend(&self) -> Option<Element> {
|
||||
self.suspended.set(true);
|
||||
None
|
||||
}
|
||||
|
||||
@@ -572,10 +572,12 @@ impl VirtualDom {
|
||||
pub async fn wait_for_suspense(&mut self) {
|
||||
loop {
|
||||
if self.suspended_scopes.is_empty() {
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
self.wait_for_work().await;
|
||||
|
||||
_ = self.render_immediate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user