remove old references to server context

This commit is contained in:
Evan Almloff committed 2023-07-07 18:39:18 -07:00
1 parent fb042df2fb
commit 41f9c480c8
5 files changed
+16 -21

No files matched your search

+3 -3
View File
@@ -74,10 +74,9 @@ fn app(cx: Scope<usize>) -> Element {
button {
onclick: move |_| {
to_owned![count];
let sc = cx.sc();
async move {
// Call the server function just like a local async function
if let Ok(new_count) = double_server(sc, *count.current()).await {
if let Ok(new_count) = double_server(*count.current()).await {
count.set(new_count);
}
}
@@ -89,7 +88,8 @@ fn app(cx: Scope<usize>) -> Element {
// We use the "getcbor" encoding to make caching easier
#[server(DoubleServer, "", "getcbor")]
async fn double_server(cx: DioxusServerContext, number: usize) -> Result<usize, ServerFnError> {
async fn double_server(number: usize) -> Result<usize, ServerFnError> {
let cx = server_context();
// Perform some expensive computation or access a database on the server
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
let result = number * 2;
+3 -3
View File
@@ -92,10 +92,9 @@ fn app(cx: Scope<usize>) -> Element {
button {
onclick: move |_| {
to_owned![count];
let sc = cx.sc();
async move {
// Call the server function just like a local async function
if let Ok(new_count) = double_server(sc, *count.current()).await {
if let Ok(new_count) = double_server(*count.current()).await {
count.set(new_count);
}
}
@@ -107,10 +106,11 @@ fn app(cx: Scope<usize>) -> Element {
// We use the "getcbor" encoding to make caching easier
#[server(DoubleServer, "", "getcbor")]
async fn double_server(cx: DioxusServerContext, number: usize) -> Result<usize, ServerFnError> {
async fn double_server(number: usize) -> Result<usize, ServerFnError> {
// Perform some expensive computation or access a database on the server
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
let result = number * 2;
let cx = server_context();
println!(
"User Agent {:?}",