Wait for the suspense boundary above the router to resolve before sending the first streaming chunk (#3891)
* Change the suspense streaming context after suspense is resolved in the router * Wait for the suspense context before streaming the first chunk in ssr * forward more response parts * warn * extract the hydration format into a crate * Fix hydration when no data is sent * forward web and server features * Fix suspense that starts on the client * fix use_server_future on the client * Add documentation for fullstack hooks and protocol * downgrade rust edition * fix clippy * fix tests * fix clippy * Fix pure web compile * undo changes to the fullstack router example * fix formatting
This commit is contained in:
1 parent
4f74ef81d1
commit
84221f55a0
45 files changed
+988
-533
No files matched your search
@@ -447,7 +447,12 @@ impl Scope {
|
||||
let mut hooks = self.hooks.try_borrow_mut().expect("The hook list is already borrowed: This error is likely caused by trying to use a hook inside a hook which violates the rules of hooks.");
|
||||
|
||||
if cur_hook >= hooks.len() {
|
||||
hooks.push(Box::new(initializer()));
|
||||
Runtime::with(|rt| {
|
||||
rt.while_not_rendering(|| {
|
||||
hooks.push(Box::new(initializer()));
|
||||
});
|
||||
})
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
self.use_hook_inner::<State>(hooks, cur_hook)
|
||||
@@ -620,4 +625,9 @@ impl ScopeId {
|
||||
pub fn throw_error(self, error: impl Into<CapturedError> + 'static) {
|
||||
throw_into(error, self)
|
||||
}
|
||||
|
||||
/// Get the suspense context the current scope is in
|
||||
pub fn suspense_context(&self) -> Option<SuspenseContext> {
|
||||
Runtime::with_scope(*self, |cx| cx.suspense_boundary.suspense_context().cloned()).unwrap()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user