-
The snippet blow logs an error when I run
Wrapping the value in use_hook changes the error to
pub enum Auth {
Login,
Logout,
Register,
}
pub fn auth_action(action: Auth) {
use_coroutine_handle::<Auth>().send(action);
}
pub async fn auth_service(mut rx: UnboundedReceiver<Auth>) {
while let Some(msg) = rx.next().await {
match msg {
Auth::Login => login().await,
Auth::Logout => logout().await,
Auth::Register => signup().await,
}
}
} How can I refactor to follow best practices? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can either use hooks directly in components or in other hooks. It looks like See also: https://dioxuslabs.com/learn/0.5/cookbook/state/custom_hooks |
Beta Was this translation helpful? Give feedback.
You can either use hooks directly in components or in other hooks. It looks like
auth_action
is a hook? If it is, you just need to add theuse_
prefix (use_auth_action
) to make it clear that it needs to be called like a hook. DX check should pass once you add the prefixSee also: https://dioxuslabs.com/learn/0.5/cookbook/state/custom_hooks