Link count of recipe to state in the service.

This commit is contained in:
Jeremy Wall 2022-02-11 20:30:38 -05:00
parent c212a453e3
commit 866483aa98
2 changed files with 5 additions and 2 deletions

View File

@ -30,9 +30,8 @@ fn recipe_check_box(props: RecipeCheckBoxProps) -> View<G> {
// the `view!` macro.
let i = props.i;
let id_as_str = Rc::new(format!("{}", i));
let id_cloned = id_as_str.clone();
let id_cloned_2 = id_as_str.clone();
let count = Signal::new(String::from("0"));
let count = Signal::new(format!("{}", app_service.get_recipe_count_by_index(i)));
view! {
input(type="number", min="0", bind:value=count.clone(), name="recipe_id", value=id_as_str.clone(), on:change=move |_| {
let mut app_service = app_service.clone();

View File

@ -86,6 +86,10 @@ impl AppService {
self.menu_list.set(v);
}
pub fn get_recipe_count_by_index(&self, i: usize) -> usize {
self.menu_list.get().get(&i).map(|i| *i).unwrap_or_default()
}
pub fn get_recipes(&self) -> Signal<Vec<(usize, Recipe)>> {
self.recipes.clone()
}