dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

Dioxus fullstack lacking a formal way to provide state

Open hgzimmerman opened this issue 1 year ago • 1 comments

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.

hgzimmerman avatar Mar 23 '24 14:03 hgzimmerman

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

ealmloff avatar Apr 18 '24 16:04 ealmloff