* improve documentation for the fullstack server context * Add a section about axum integration to the crate root docs * make serve_dioxus_application accept the cfg builder directly * remove unused server_fn module * improve fullstack config docs * improve documentation for the server function macro * fix axum router extension link * Fix doc tests * Fix launch builder * Simplify the launch builder * don't re-export launch in the prelude * refactor fullstack launch * Fix fullstack launch builder * Update static generation with the new builder api * fix some formatting/overly broad launch replacements * fix custom menu example * fix fullstack/static generation examples * Fix static generation launch * A few small formatting fixes * Fix a few doc tests * implement LaunchConfig for serve configs * fix fullstack launch with separate web and server launch methods * fix check with all features * dont expose inner core module * clippy and check * fix readme --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
112 lines
2.6 KiB
Rust
112 lines
2.6 KiB
Rust
// This test is used by playwright configured in the root of the repo
|
|
// Tests:
|
|
// - Streaming hydration
|
|
// - Suspense
|
|
// - Server futures
|
|
|
|
#![allow(non_snake_case, unused)]
|
|
use dioxus::prelude::*;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
fn app() -> Element {
|
|
let mut count = use_signal(|| 0);
|
|
|
|
rsx! {
|
|
button {
|
|
id: "increment-carousel-button",
|
|
onclick: move |_| count += 1,
|
|
"Increment"
|
|
}
|
|
button {
|
|
id: "decrement-carousel-button",
|
|
onclick: move |_| count -= 1,
|
|
"Decrement"
|
|
}
|
|
div {
|
|
"Hello world"
|
|
}
|
|
div {
|
|
for i in count()..count() + 3 {
|
|
SuspenseBoundary {
|
|
key: "{i}",
|
|
fallback: |_| rsx! {
|
|
"Loading..."
|
|
},
|
|
SuspendedComponent {
|
|
id: i
|
|
}
|
|
}
|
|
}
|
|
}
|
|
div { "footer 123" }
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
|
|
enum ResolvedOn {
|
|
Server,
|
|
Client,
|
|
}
|
|
|
|
impl ResolvedOn {
|
|
#[cfg(feature = "web")]
|
|
const CURRENT: Self = Self::Client;
|
|
#[cfg(not(feature = "web"))]
|
|
const CURRENT: Self = Self::Server;
|
|
}
|
|
|
|
#[component]
|
|
fn SuspendedComponent(id: i32) -> Element {
|
|
let resolved_on = use_server_future(move || async move {
|
|
async_std::task::sleep(std::time::Duration::from_secs(1)).await;
|
|
ResolvedOn::CURRENT
|
|
})?()
|
|
.unwrap();
|
|
|
|
let mut count = use_signal(|| 0);
|
|
|
|
rsx! {
|
|
div {
|
|
id: "outer-{id}",
|
|
"outer suspense result: {resolved_on:?}"
|
|
button {
|
|
id: "outer-button-{id}",
|
|
onclick: move |_| count += 1,
|
|
"{count}"
|
|
}
|
|
SuspenseBoundary {
|
|
fallback: |_| rsx! {
|
|
"Loading... more"
|
|
},
|
|
NestedSuspendedComponent {
|
|
id
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#[component]
|
|
fn NestedSuspendedComponent(id: i32) -> Element {
|
|
let resolved_on = use_server_future(move || async move {
|
|
async_std::task::sleep(std::time::Duration::from_secs(1)).await;
|
|
ResolvedOn::CURRENT
|
|
})?()
|
|
.unwrap();
|
|
let mut count = use_signal(|| 0);
|
|
rsx! {
|
|
div {
|
|
"nested suspense result: {resolved_on:?}"
|
|
button {
|
|
id: "nested-button-{id}",
|
|
onclick: move |_| count += 1,
|
|
"{count}"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
dioxus::launch(app);
|
|
}
|