mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 14:54:16 +00:00
This commit is contained in:
parent
2bafdf2752
commit
4e41fad107
2 changed files with 13 additions and 2 deletions
|
@ -787,12 +787,20 @@ async fn build_stream_response(
|
|||
scope: ScopeId,
|
||||
) -> HttpResponse {
|
||||
let cx = leptos::Scope { runtime, id: scope };
|
||||
let mut stream = Box::pin(stream);
|
||||
|
||||
// wait for any blocking resources to load before pulling metadata
|
||||
let first_app_chunk = stream.next().await.unwrap_or_default();
|
||||
|
||||
let (head, tail) =
|
||||
html_parts_separated(options, use_context::<MetaContext>(cx).as_ref());
|
||||
|
||||
let mut stream = Box::pin(
|
||||
futures::stream::once(async move { head.clone() })
|
||||
.chain(stream)
|
||||
.chain(
|
||||
futures::stream::once(async move { first_app_chunk })
|
||||
.chain(stream),
|
||||
)
|
||||
.chain(futures::stream::once(async move {
|
||||
runtime.dispose();
|
||||
tail.to_string()
|
||||
|
|
|
@ -685,11 +685,14 @@ async fn forward_stream(
|
|||
mut tx: Sender<String>,
|
||||
) {
|
||||
let cx = Scope { runtime, id: scope };
|
||||
let mut shell = Box::pin(bundle);
|
||||
let first_app_chunk = shell.next().await.unwrap_or_default();
|
||||
|
||||
let (head, tail) =
|
||||
html_parts_separated(options, use_context::<MetaContext>(cx).as_ref());
|
||||
|
||||
_ = tx.send(head).await;
|
||||
let mut shell = Box::pin(bundle);
|
||||
_ = tx.send(first_app_chunk).await;
|
||||
while let Some(fragment) = shell.next().await {
|
||||
_ = tx.send(fragment).await;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue