Skip to content

Commit

Permalink
Add demo of hydrating suspensed content
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechu10 committed Sep 16, 2024
1 parent 9dea370 commit 1d45224
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions examples/ssr-streaming/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ fn DelayedText(delay_ms: u64) -> View {
}
}

#[component]
fn CounterButton() -> View {
let mut state = create_signal(0);

view! {
button(r#type="button", on:click=move |_| state += 1) {
(state.get())
}
}
}

#[component]
fn App() -> View {
let delays = [1000, 2000, 1000];
Expand Down Expand Up @@ -83,6 +94,15 @@ fn App() -> View {
DelayedText(delay_ms=1000)
}
}

p {
strong { "Suspense content is hydrated" }
}
Suspense(fallback=|| view! { "Loading interactive content..."}) {
Delayed(delay_ms=1000) {
CounterButton {}
}
}
}
}

Expand Down

0 comments on commit 1d45224

Please sign in to comment.