From 871d2c1b9fa0da83652a88ca2f0c0446c16cbc45 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Tue, 9 Apr 2024 14:45:01 -0400 Subject: [PATCH 1/2] feat: directly implement `IntoView` on resources on stable --- leptos_dom/src/lib.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/leptos_dom/src/lib.rs b/leptos_dom/src/lib.rs index 20dcc3fca7..30124174fd 100644 --- a/leptos_dom/src/lib.rs +++ b/leptos_dom/src/lib.rs @@ -45,7 +45,8 @@ use html::{AnyElement, ElementDescriptor}; pub use hydration::{HydrationCtx, HydrationKey}; #[cfg(not(feature = "nightly"))] use leptos_reactive::{ - MaybeProp, MaybeSignal, Memo, ReadSignal, RwSignal, Signal, SignalGet, + MaybeProp, MaybeSignal, Memo, ReadSignal, Resource, RwSignal, Signal, + SignalGet, }; use leptos_reactive::{Oco, TextProp}; pub use macro_helpers::*; @@ -207,6 +208,20 @@ where } } #[cfg(not(feature = "nightly"))] +impl IntoView for Resource +where + S: Clone, + T: IntoView + Clone, +{ + #[cfg_attr( + any(debug_assertions, feature = "ssr"), + instrument(level = "trace", name = "Signal", skip_all) + )] + fn into_view(self) -> View { + DynChild::new(move || self.get()).into_view() + } +} +#[cfg(not(feature = "nightly"))] impl IntoView for MaybeSignal where T: IntoView + Clone, From 85a91af7c6a4a86ee314d83d6143a703ee39daf2 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Tue, 9 Apr 2024 14:45:19 -0400 Subject: [PATCH 2/2] examples: simplify stable syntax for using signals in view --- examples/counter/src/lib.rs | 2 +- examples/counters/src/lib.rs | 2 +- examples/hackernews_axum/src/error_template.rs | 2 +- .../hackernews_islands_axum/src/error_template.rs | 2 +- .../hackernews_islands_axum/src/routes/story.rs | 2 +- examples/hackernews_js_fetch/src/error_template.rs | 2 +- examples/hackernews_js_fetch/src/routes/story.rs | 2 +- examples/js-framework-benchmark/src/lib.rs | 4 ++-- examples/parent_child/src/lib.rs | 8 ++++---- examples/portal/src/lib.rs | 4 ++-- examples/server_fns_axum/src/app.rs | 14 ++++++-------- examples/slots/src/lib.rs | 2 +- examples/sso_auth_axum/src/lib.rs | 2 +- examples/tailwind_axum/src/app.rs | 2 +- examples/timer/src/lib.rs | 6 +++--- examples/todomvc/src/lib.rs | 8 ++++---- 16 files changed, 31 insertions(+), 33 deletions(-) diff --git a/examples/counter/src/lib.rs b/examples/counter/src/lib.rs index 66b0e90dcd..7b3b43461d 100644 --- a/examples/counter/src/lib.rs +++ b/examples/counter/src/lib.rs @@ -16,7 +16,7 @@ pub fn SimpleCounter(
- "Value: " {move || value.get()} "!" + "Value: " {value} "!"
} diff --git a/examples/counters/src/lib.rs b/examples/counters/src/lib.rs index 3df34397c7..5460322da9 100644 --- a/examples/counters/src/lib.rs +++ b/examples/counters/src/lib.rs @@ -63,7 +63,7 @@ pub fn Counters() -> impl IntoView {