codify "platform" into resolution logic, server-fn/fullstack overhaul (#4596)

overhaul dioxus fullstack using a new implementation of server_fn

This PR is a complete rewrite of dioxus fullstack designed to improve compatibility with axum and to fix a number of compilation errors based on feature flag unification plumbing through macros.
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2025-10-03 18:26:19 -07:00
1 parent 8421c3aef0
commit f2b1c6d97f
424 files changed
+17284 -6624

No files matched your search

+26 -2
View File
@@ -1,13 +1,16 @@
#![allow(missing_docs)]
use crate::{use_callback, use_signal};
use crate::{use_callback, use_signal, use_waker, UseWaker};
use dioxus_core::{
spawn, use_hook, Callback, IntoAttributeValue, IntoDynNode, ReactiveContext, RenderError,
Subscribers, SuspendedFuture, Task,
};
use dioxus_signals::*;
use futures_util::{future, pin_mut, FutureExt, StreamExt};
use futures_util::{
future::{self},
pin_mut, FutureExt, StreamExt,
};
use std::ops::Deref;
use std::{cell::Cell, future::Future, rc::Rc};
@@ -31,6 +34,8 @@ where
(rc, Rc::new(Cell::new(Some(changed))))
});
let mut waker = use_waker::<()>();
let cb = use_callback(move |_| {
// Set the state to Pending when the task is restarted
state.set(UseResourceState::Pending);
@@ -57,6 +62,9 @@ where
// Set the value and state
state.set(UseResourceState::Ready);
value.set(Some(res));
// Notify that the value has changed
waker.wake(());
})
});
@@ -82,6 +90,7 @@ where
task,
value,
state,
waker,
callback: cb,
}
}
@@ -113,6 +122,7 @@ where
/// ```
#[derive(Debug)]
pub struct Resource<T: 'static> {
waker: UseWaker<()>,
value: Signal<Option<T>>,
task: Signal<Task>,
state: Signal<UseResourceState>,
@@ -486,3 +496,17 @@ impl<T: Clone> Deref for Resource<T> {
unsafe { ReadableExt::deref_impl(self) }
}
}
impl<T> std::future::Future for Resource<T> {
type Output = ();
fn poll(
self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Self::Output> {
match self.waker.clone().poll_unpin(cx) {
std::task::Poll::Ready(_) => std::task::Poll::Ready(()),
std::task::Poll::Pending => std::task::Poll::Pending,
}
}
}