Skip to content

Commit

Permalink
feat(webapp): request_action now accepts a then argument
Browse files Browse the repository at this point in the history
This is useful to process the result of the `handle_request` within
the server action, or to perform some side effect before returning.
  • Loading branch information
W95Psp committed Feb 16, 2024
1 parent 0d639c7 commit 8b7deb5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions typhon-webapp/src/handle_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Result<(), responses::ResponseError>, ServerFnError> {
handle_request!(
let $res = handle_request!(
$body,
|_| ()
)
);
$then
}
create_server_action::<$name>()
}
Expand Down

0 comments on commit 8b7deb5

Please sign in to comment.