How should I run code when Action done #2275
-
I have a event function: let handle_send_captcha = move |ev: SubmitEvent| {
ev.prevent_default();
action.dispatch("params".to_string());
// to something when action done
} I trigger it by click a button, and I want to do something after action done. any good idea? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I think I have found a way, directly write your code in closure parameter of create_action, let captcha_valid_action = create_action(|input: &(String, String)| {
let (email, captcha) = input.clone();
async move {
let res = valid_captcha(&email, &captcha).await;
// do something here
logging::log!("end");
res
}
}); but I do not know if there is a better idea |
Beta Was this translation helpful? Give feedback.
-
There are two possibilities:
|
Beta Was this translation helpful? Give feedback.
There are two possibilities:
create_effect
and track the.value()
signal of the action