From f55375b8ce0fa0220a2c4d49029c936b4cb8c164 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Wed, 19 Jul 2023 16:57:43 -0700 Subject: [PATCH] simplify fullstack hello world examples --- .../fullstack/examples/axum-hello-world/src/main.rs | 10 ++-------- .../fullstack/examples/salvo-hello-world/src/main.rs | 10 ++-------- .../fullstack/examples/warp-hello-world/src/main.rs | 10 ++-------- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/packages/fullstack/examples/axum-hello-world/src/main.rs b/packages/fullstack/examples/axum-hello-world/src/main.rs index 8a460c685..a5724f8ee 100644 --- a/packages/fullstack/examples/axum-hello-world/src/main.rs +++ b/packages/fullstack/examples/axum-hello-world/src/main.rs @@ -22,14 +22,8 @@ fn app(cx: Scope) -> Element { } fn Child(cx: Scope) -> Element { - let state = use_server_future(cx, (), |()| async move { - loop { - if let Ok(res) = get_server_data().await { - break res; - } - } - })? - .value(); + let state = + use_server_future(cx, (), |()| async move { get_server_data().await.unwrap() })?.value(); let mut count = use_state(cx, || 0); let text = use_state(cx, || "...".to_string()); diff --git a/packages/fullstack/examples/salvo-hello-world/src/main.rs b/packages/fullstack/examples/salvo-hello-world/src/main.rs index d9dcea86f..09c68e1f4 100644 --- a/packages/fullstack/examples/salvo-hello-world/src/main.rs +++ b/packages/fullstack/examples/salvo-hello-world/src/main.rs @@ -22,14 +22,8 @@ fn app(cx: Scope) -> Element { } fn Child(cx: Scope) -> Element { - let state = use_server_future(cx, (), |()| async move { - loop { - if let Ok(res) = get_server_data().await { - break res; - } - } - })? - .value(); + let state = + use_server_future(cx, (), |()| async move { get_server_data().await.unwrap() })?.value(); let mut count = use_state(cx, || 0); let text = use_state(cx, || "...".to_string()); diff --git a/packages/fullstack/examples/warp-hello-world/src/main.rs b/packages/fullstack/examples/warp-hello-world/src/main.rs index d9dcea86f..09c68e1f4 100644 --- a/packages/fullstack/examples/warp-hello-world/src/main.rs +++ b/packages/fullstack/examples/warp-hello-world/src/main.rs @@ -22,14 +22,8 @@ fn app(cx: Scope) -> Element { } fn Child(cx: Scope) -> Element { - let state = use_server_future(cx, (), |()| async move { - loop { - if let Ok(res) = get_server_data().await { - break res; - } - } - })? - .value(); + let state = + use_server_future(cx, (), |()| async move { get_server_data().await.unwrap() })?.value(); let mut count = use_state(cx, || 0); let text = use_state(cx, || "...".to_string());