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:
Evan Almloff authored and GitHub committed 2025-04-08 16:01:21 -05:00
1 parent 4f74ef81d1
commit 84221f55a0
45 files changed
+988 -533

No files matched your search

+6
View File
@@ -2,7 +2,13 @@
#[cfg(feature = "server")]
pub mod server;
use dioxus_fullstack_protocol::SerializeContextEntry;
#[cfg(feature = "server")]
pub use server::ServerDocument;
#[cfg(all(feature = "web", feature = "document"))]
pub mod web;
#[allow(unused)]
pub(crate) fn head_element_hydration_entry() -> SerializeContextEntry<bool> {
dioxus_fullstack_protocol::serialize_context().create_entry()
}
+2 -2
View File
@@ -64,8 +64,8 @@ impl ServerDocument {
// We only serialize the head elements if the web document feature is enabled
#[cfg(feature = "document")]
{
let serialize = crate::html_storage::serialize_context();
serialize.push(&!self.0.borrow().streaming, std::panic::Location::caller());
super::head_element_hydration_entry()
.insert(&!self.0.borrow().streaming, std::panic::Location::caller());
}
}
}
+4 -2
View File
@@ -4,10 +4,12 @@
use dioxus_lib::{document::*, prelude::queue_effect};
use dioxus_web::WebDocument;
use super::head_element_hydration_entry;
fn head_element_written_on_server() -> bool {
dioxus_web::take_server_data()
head_element_hydration_entry()
.get()
.ok()
.flatten()
.unwrap_or_default()
}