From 016ec78e6921707190ef760a7958d7adbb451ab9 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Fri, 13 Jun 2025 11:10:56 -0400 Subject: [PATCH] fix example code on resources --- src/async/10_resources.md | 50 --------------------------------------- 1 file changed, 50 deletions(-) diff --git a/src/async/10_resources.md b/src/async/10_resources.md index 96f3c1e..f6eb6fb 100644 --- a/src/async/10_resources.md +++ b/src/async/10_resources.md @@ -94,56 +94,6 @@ async fn load_data(value: i32) -> i32 { value * 10 } -#[component] -pub fn App() -> impl IntoView { - // this count is our synchronous, local state - let (count, set_count) = signal(0); - - // tracks `count`, and reloads by calling `load_data` - // whenever it changes - let async_data = LocalResource::new(move || load_data(count.get())); - - // a resource will only load once if it doesn't read any reactive data - let stable = LocalResource::new(|| load_data(1)); - - // we can access the resource values with .get() -use gloo_timers::future::TimeoutFuture; -use leptos::prelude::*; - -// Here we define an async function -// This could be anything: a network request, database read, etc. -// Here, we just multiply a number by 10 -async fn load_data(value: i32) -> i32 { - // fake a one-second delay - TimeoutFuture::new(1_000).await; - value * 10 -} - -#[component] -pub fn App() -> impl IntoView { - // this count is our synchronous, local state - let (count, set_count) = signal(0); - - // tracks `count`, and reloads by calling `load_data` - // whenever it changes - let async_data = LocalResource::new(move || load_data(count.get())); - - // a resource will only load once if it doesn't read any reactive data - let stable = LocalResource::new(|| load_data(1)); - - // we can access the resource values with .get() -use gloo_timers::future::TimeoutFuture; -use leptos::prelude::*; - -// Here we define an async function -// This could be anything: a network request, database read, etc. -// Here, we just multiply a number by 10 -async fn load_data(value: i32) -> i32 { - // fake a one-second delay - TimeoutFuture::new(1_000).await; - value * 10 -} - #[component] pub fn App() -> impl IntoView { // this count is our synchronous, local state