From fca8c6fa2f071f6fcb4235707c962327932191da Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Mon, 9 Dec 2024 13:56:39 +0300 Subject: [PATCH] fix(app): enhance signal management in App component - Switched from `create_signal` to a tuple-based signal declaration using `(items_signal, set_items)` for improved clarity. - Replaced `items.update` with a closure-based update approach for `set_items`. - Added `Box::new` to `ItemForm`'s `on_submit` to properly handle the function's lifetime and scope. - Removed unused imports for `leptos_meta` and `leptos_router` to clean up the code. --- src/app.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/app.rs b/src/app.rs index 82836ba..8edd2f8 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,16 +1,13 @@ use leptos::*; -use leptos_meta::*; -use leptos_router::*; use crate::components::{item_form::ItemForm, items_list::ItemsList}; use crate::models::item::Item; -use std::sync::Arc; #[component] pub fn App() -> impl IntoView { - let items = create_signal(Vec::::new()); + let (items_signal, set_items) = create_signal(Vec::::new()); let add_item = move |name: String, description: String, tags: Vec<(String, String)>| { - items.update(|items| { + set_items;(|mut items: Vec| { items.push(Item { id: uuid::Uuid::new_v4().to_string(), name, @@ -23,8 +20,8 @@ pub fn App() -> impl IntoView { view! {

CompareWare

- - + +
} } \ No newline at end of file