From 8b7deb55dcacaccb456a635a77b05dc27dec7db2 Mon Sep 17 00:00:00 2001 From: Lucas Franceschino Date: Fri, 16 Feb 2024 22:41:08 +0100 Subject: [PATCH] feat(webapp): request_action now accepts a `then` argument This is useful to process the result of the `handle_request` within the server action, or to perform some side effect before returning. --- typhon-webapp/src/handle_request.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/typhon-webapp/src/handle_request.rs b/typhon-webapp/src/handle_request.rs index 8b66c346..f8051924 100644 --- a/typhon-webapp/src/handle_request.rs +++ b/typhon-webapp/src/handle_request.rs @@ -115,16 +115,20 @@ macro_rules! search { } macro_rules! request_action { - ($name:ident, |$($id:ident : $ty:ty),*| $body: expr) => { + ($name:ident, |$($id:ident : $ty:ty),*| $body: expr$(,)?) => { + crate::handle_request::request_action!($name, |$($id : $ty),*| $body, |res| res) + }; + ($name:ident, |$($id:ident : $ty:ty),*| $body: expr, |$res:ident| $then: expr$(,)?) => { { #[server($name, "/leptos")] async fn f( $($id : $ty,)* ) -> Result, ServerFnError> { - handle_request!( + let $res = handle_request!( $body, |_| () - ) + ); + $then } create_server_action::<$name>() }