@@ -79,9 +79,7 @@ pub fn HomePage() -> impl IntoView {
7979}
8080
8181#[ component]
82- pub fn UsingSignal (
83- rs : ReadSignal < Option < OnceResource < String > > > ,
84- ) -> impl IntoView {
82+ pub fn UsingSignal ( rs : ReadSignal < Option < OnceResource < String > > > ) -> impl IntoView {
8583 // Ready will have _no_ effect whatsoever if this component is not
8684 // enclosed by the `SyncSsr` component.
8785 // #[cfg(feature = "ssr")]
@@ -100,16 +98,19 @@ pub fn UsingSignal(
10098 // #[cfg(feature = "ssr")]
10199 ready. subscribe ( ) . wait ( ) . await ;
102100 // leptos::logging::log!("subscription finished waiting");
103- let value = if let Some ( Some ( res) ) = rs. try_get ( ) {
101+ // let value = if let Some(Some(res)) = rs.try_get() {
102+ if let Some ( Some ( res) ) = rs. try_get ( ) {
104103 // leptos::logging::log!("readsignal has OnceResource");
105- let result = Some ( res. await ) ;
104+ // let result = Some(res.await);
106105 // leptos::logging::log!("finished awaiting for OnceResource");
107- result
106+ // result
107+ Some ( res. await )
108108 } else {
109109 None
110- } ;
110+ }
111+ // };
111112 // leptos::logging::log!("value: {value:?}");
112- value
113+ // value
113114 }
114115 } ,
115116 ) ;
@@ -120,18 +121,22 @@ pub fn UsingSignal(
120121 <Suspense >{
121122 move || Suspend :: new( async move {
122123 // leptos::logging::log!("Inside suspense");
123- let result = if let Some ( value) = value. await {
124- // leptos::logging::log!("value.await got Some");
125- Some ( view! {
126- <strong id="target" >{ value} </strong>
127- }
128- . into_any( ) )
129- } else {
130- // leptos::logging::log!("value.await got None");
131- None
132- } ;
124+ // let result = if let Some(value) = value.await {
125+ // leptos::logging::log!("value.await got Some");
126+ // Some(view! {
127+ // <strong id="target">{value}</strong>
128+ // }
129+ // .into_any())
130+ // } else {
131+ // leptos::logging::log!("value.await got None");
132+ // None
133+ // };
133134 // leptos::logging::log!("Suspense rendered");
134- result
135+ // result
136+ value. await . map( |value| view! {
137+ <strong id="target" >{ value} </strong>
138+ }
139+ . into_any( ) )
135140 } )
136141 } </Suspense >
137142 "."
@@ -140,29 +145,24 @@ pub fn UsingSignal(
140145}
141146
142147#[ component]
143- pub fn SettingSignal (
144- ws : WriteSignal < Option < OnceResource < String > > > ,
145- ) -> impl IntoView {
148+ pub fn SettingSignal ( ws : WriteSignal < Option < OnceResource < String > > > ) -> impl IntoView {
146149 on_cleanup ( move || {
147150 // leptos::logging::log!("Running on_cleanup");
148151 ws. try_set ( None ) ;
149152 } ) ;
150153
151- let server_call = Resource :: new_blocking (
152- || ( ) ,
153- |_| async move {
154- server_call ( ) . await
155- } ,
156- ) ;
154+ let server_call = Resource :: new_blocking ( || ( ) , |_| async move { server_call ( ) . await } ) ;
157155
158156 let static_value = "Hello World!" ;
159157 // while the resource can be set via the signal directly here, having
160158 // a hook that gets called when the view is initiated emulates a kind
161159 // of reactivity that would determine whether or not it is set.
162- let hook = move || ws. set ( Some ( OnceResource :: new ( async move {
163- let _ = server_call. await ;
164- static_value. to_string ( )
165- } ) ) ) ;
160+ let hook = move || {
161+ ws. set ( Some ( OnceResource :: new ( async move {
162+ let _ = server_call. await ;
163+ static_value. to_string ( )
164+ } ) ) )
165+ } ;
166166 view ! {
167167 { hook}
168168 // If the following block is inside a Suspense that awaits some
@@ -223,8 +223,7 @@ pub fn NonIssue() -> impl IntoView {
223223
224224#[ component]
225225pub fn HydrationIssue (
226- #[ prop( default = "Below can result in hydration issue" ) ]
227- title : & ' static str ,
226+ #[ prop( default = "Below can result in hydration issue" ) ] title : & ' static str ,
228227 children : Children ,
229228) -> impl IntoView {
230229 let ( rs, ws) = signal ( None :: < OnceResource < String > > ) ;
0 commit comments