Cleanup naming for AppService

This commit is contained in:
Jeremy Wall 2022-01-25 21:14:30 -05:00
parent d6722adb4d
commit 74b432ad24

View File

@ -72,12 +72,12 @@ impl AppService {
/// Component to list available recipes. /// Component to list available recipes.
#[component(RecipeList<G>)] #[component(RecipeList<G>)]
fn recipe_list() -> View<G> { fn recipe_list() -> View<G> {
let props = use_context::<AppService>(); let app_service = use_context::<AppService>();
view! { view! {
ul { ul {
Indexed(IndexedProps{ Indexed(IndexedProps{
iterable: props.get_recipes().handle(), iterable: app_service.get_recipes().handle(),
template: |recipe| { template: |recipe| {
view! { li { (recipe.title) } } view! { li { (recipe.title) } }
} }
@ -88,14 +88,14 @@ fn recipe_list() -> View<G> {
#[component(UI<G>)] #[component(UI<G>)]
pub fn ui() -> View<G> { pub fn ui() -> View<G> {
let app_state = AppService::new(); let app_service = AppService::new();
console_log!("Starting UI"); console_log!("Starting UI");
spawn_local_in_scope({ spawn_local_in_scope({
let mut app_state = app_state.clone(); let mut app_service = app_service.clone();
async move { async move {
match AppService::fetch_recipes().await { match AppService::fetch_recipes().await {
Ok(recipes) => { Ok(recipes) => {
app_state.set_recipes(recipes); app_service.set_recipes(recipes);
} }
Err(msg) => console_error!("Failed to get recipes {}", msg), Err(msg) => console_error!("Failed to get recipes {}", msg),
} }
@ -104,7 +104,7 @@ pub fn ui() -> View<G> {
view! { view! {
div { "hello chefs!" } div { "hello chefs!" }
ContextProvider(ContextProviderProps { ContextProvider(ContextProviderProps {
value: app_state, value: app_service,
children: || view! { RecipeList() } children: || view! { RecipeList() }
}) })
} }