DioxusLabs / dioxus

Fullstack GUI library for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
19.35k stars 740 forks source link

Dioxus fullstack lacking a formal way to provide state #2131

Closed hgzimmerman closed 2 weeks ago

hgzimmerman commented 3 months ago

Feature Request

In https://github.com/DioxusLabs/dioxus/pull/1944, DioxusRouterExt::register_server_fns_with_handler was removed without providing a suitable replacement. I used this method to provide state to Axum so that it could be extracted in the #[server(..)] functions. I know it is otherwise possible using Axum layers, but that isn't particularly ergonomic at the moment.

Observed in Dioxus 0.5.0-alpha-2

Implement Suggestion

It was suggested in Discord that the following function could be made public or form the basis of another public function: https://github.com/DioxusLabs/dioxus/blob/b19a546c0ac639a5cf9e942fff7729ad30e91a5e/packages/fullstack/src/axum_adapter.rs#L485

What strikes me as odd is that the argument's type signature is impl Fn() + 'static + Clone + Send, when I think it should be impl Fn(&mut DioxusServerContext) + 'static + Clone + Send,, so that there is a context to modify.

ealmloff commented 2 months ago

This is also related to https://github.com/DioxusLabs/dioxus/issues/1688 which is a more broad issue about how to pass state, and layers to the server in dioxus fullstack