From 53e16751a7fabf2708d3871c22de1022962c9875 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Wed, 11 Oct 2023 16:45:48 -0400 Subject: [PATCH] chore: clean up style and bring into line with other hackernews examples --- examples/hackernews_js_fetch/Cargo.toml | 15 ++-- examples/hackernews_js_fetch/src/api.rs | 3 +- examples/hackernews_js_fetch/src/lib.rs | 44 ++++------ examples/hackernews_js_fetch/src/routes.rs | 1 - .../src/routes/counters.rs | 79 ------------------ .../hackernews_js_fetch/src/routes/stories.rs | 35 ++++---- .../hackernews_js_fetch/src/routes/story.rs | 81 +++++++++---------- .../hackernews_js_fetch/src/routes/users.rs | 6 +- 8 files changed, 84 insertions(+), 180 deletions(-) delete mode 100644 examples/hackernews_js_fetch/src/routes/counters.rs diff --git a/examples/hackernews_js_fetch/Cargo.toml b/examples/hackernews_js_fetch/Cargo.toml index 99b2ff656c..daf2ca52fc 100644 --- a/examples/hackernews_js_fetch/Cargo.toml +++ b/examples/hackernews_js_fetch/Cargo.toml @@ -27,15 +27,20 @@ reqwest = { version = "0.11.13", features = ["json"] } axum = { version = "0.6", default-features = false, optional = true } tower = { version = "0.4.13", optional = true } http = { version = "0.2.8", optional = true } -web-sys = { version = "0.3", features = ["AbortController", "AbortSignal", "Request", "Response"] } +web-sys = { version = "0.3", features = [ + "AbortController", + "AbortSignal", + "Request", + "Response", +] } wasm-bindgen = "0.2" -wasm-bindgen-futures = { version = "0.4.37", features = ["futures-core-03-stream"], optional = true } +wasm-bindgen-futures = { version = "0.4.37", features = [ + "futures-core-03-stream", +], optional = true } axum-js-fetch = { version = "0.2.1", optional = true } lazy_static = "1.4.0" [features] -default = ["csr"] -csr = ["leptos/csr", "leptos_meta/csr", "leptos_router/csr"] hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate"] ssr = [ "dep:tower", @@ -51,7 +56,7 @@ ssr = [ [package.metadata.cargo-all-features] denylist = ["axum", "tower", "http", "leptos_axum"] -skip_feature_sets = [["csr", "ssr"], ["csr", "hydrate"], ["ssr", "hydrate"]] +skip_feature_sets = [["ssr", "hydrate"]] [package.metadata.leptos] # The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name diff --git a/examples/hackernews_js_fetch/src/api.rs b/examples/hackernews_js_fetch/src/api.rs index b30bbb3cc1..99c44c6e3a 100644 --- a/examples/hackernews_js_fetch/src/api.rs +++ b/examples/hackernews_js_fetch/src/api.rs @@ -17,8 +17,7 @@ where let abort_controller = web_sys::AbortController::new().ok(); let abort_signal = abort_controller.as_ref().map(|a| a.signal()); - // abort in-flight requests if the Scope is disposed - // i.e., if we've navigated away from this page + // abort in-flight requests if, e.g., we've navigated away from this page leptos::on_cleanup(move || { if let Some(abort_controller) = abort_controller { abort_controller.abort() diff --git a/examples/hackernews_js_fetch/src/lib.rs b/examples/hackernews_js_fetch/src/lib.rs index 3bee19e8fc..014a1f32c3 100644 --- a/examples/hackernews_js_fetch/src/lib.rs +++ b/examples/hackernews_js_fetch/src/lib.rs @@ -2,42 +2,35 @@ use cfg_if::cfg_if; use leptos::{component, view, IntoView}; use leptos_meta::*; use leptos_router::*; -use log::{info, Level}; mod api; pub mod error_template; pub mod fallback; mod routes; -use routes::{counters::*, nav::*, stories::*, story::*, users::*}; +use routes::{nav::*, stories::*, story::*, users::*}; +use wasm_bindgen::prelude::wasm_bindgen; #[component] pub fn App() -> impl IntoView { provide_meta_context(); view! { - - <> - - - - -