dioxus/packages
Ben Sully 04fd2487b3
feat(fullstack): add render_handler_with_state (#1687)
* feat(fullstack): add `render_handler_with_state`

When using server functions, the current pattern to access state such as
database connections is to use `register_server_fns_with_handler` on an
Axum router and 'inject' the state into the context provided to the
server function. However, this only affects function calls which go via
the Axum router; SSR renders bypass this, and therefore don't have
access to any state.

This commit adds an alternative `render_handler` which accepts some
additional state. That state is injected into the context in a
similar manner to `register_server_fns_with_handler`. SSR renders can
then proceed to run in the same way as HTTP calls.

* Change state object to 'inject_state' callback

Also add a compiling doctest example.

* remove the explicit for<'a> lifetime

* remove unused assets_path from render_handler_with_context example

---------

Co-authored-by: Evan Almloff <evanalmloff@gmail.com>
2023-12-05 14:10:18 -06:00
..
autofmt Include README and Dioxus logo in package docs (#1536) 2023-10-10 10:52:48 -05:00
check Include README and Dioxus logo in package docs (#1536) 2023-10-10 10:52:48 -05:00
cli Fixed conflict of "--verbose" and "--quiet" flags (#1686) 2023-12-04 18:11:02 -06:00
core remove #[doc(hidden)] from EventHandler (#1665) 2023-11-27 15:45:29 -06:00
core-macro Allow warning in necessary functions (#1626) 2023-11-09 12:31:59 -06:00
desktop docs(desktop): fix wrong example code (#1678) 2023-12-01 07:52:20 -06:00
dioxus Include README and Dioxus logo in package docs (#1536) 2023-10-10 10:52:48 -05:00
dioxus-tui Include README and Dioxus logo in package docs (#1536) 2023-10-10 10:52:48 -05:00
extension Bump crate versions, fix any publish errors 2023-07-31 18:49:54 -07:00
fermi Update atom_root.rs (#1611) 2023-11-04 14:04:14 -05:00
fullstack feat(fullstack): add render_handler_with_state (#1687) 2023-12-05 14:10:18 -06:00
generational-box Fix typo in generational box readme 2023-10-19 13:03:26 -05:00
hooks Add use_const hook (#1667) 2023-11-28 09:51:09 -06:00
hot-reload feat: Optional web support for hot-reload crate (#1527) 2023-10-20 12:59:49 -05:00
html Add it (#1660) 2023-11-23 16:44:39 -06:00
interpreter feat: initial_checked attribute for inputs (#1540) 2023-10-12 08:12:09 -05:00
liveview Include README and Dioxus logo in package docs (#1536) 2023-10-10 10:52:48 -05:00
mobile Include README and Dioxus logo in package docs (#1536) 2023-10-10 10:52:48 -05:00
native-core Include README and Dioxus logo in package docs (#1536) 2023-10-10 10:52:48 -05:00
native-core-macro Include README and Dioxus logo in package docs (#1536) 2023-10-10 10:52:48 -05:00
rink Switch outdated tui crate for ratatui (#1671) 2023-11-28 16:54:17 -06:00
router Implement LiveView Router Integration (#1505) 2023-10-26 14:19:51 -05:00
router-macro Include README and Dioxus logo in package docs (#1536) 2023-10-10 10:52:48 -05:00
rsx Add into_vnode temporary logic for more things 2023-10-17 15:42:21 -07:00
rsx-rosetta Include README and Dioxus logo in package docs (#1536) 2023-10-10 10:52:48 -05:00
server-macro Updated server_fn to 0.5.2 (#1620) 2023-11-08 08:33:41 -06:00
signals Merge pull request #1551 from ealmloff/fix-signals-outside-of-runtime 2023-10-23 15:32:12 -04:00
ssr Include README and Dioxus logo in package docs (#1536) 2023-10-10 10:52:48 -05:00
web fix the scroll event on the web renderer 2023-11-02 21:00:43 -05:00