Properly implement wait_for_suspense

Wait_for_suspense now does not call flush_sync, making it
appropriate for deferring effects on the server. Futures will
still run on the server (as needed to progress suspense)
but use_effect / and memo watchers will not run on the server
This commit is contained in:
Jonathan Kelley committed 2024-01-29 14:12:05 -08:00
1 parent 1f88103dca
commit dcdada542b
11 files changed
+156 -86

No files matched your search

+11
View File
@@ -17,6 +17,17 @@ fn app() -> Element {
// effects will always run after first mount and then whenever the signal values change
use_effect(move || println!("Count changed to {}", count()));
// We can do early returns and conditional rendering which will pause all futures that haven't been polled
if count() > 30 {
return rsx! {
h1 { "Count is too high!" }
button {
onclick: move |_| count.set(0),
"Press to reset"
}
};
}
// use_future will spawn an infinitely running future that can be started and stopped
use_future(|| async move {
loop {