Skip to content

How to handle form submission / async events / closures #406

Answered by lukechu10
seanpmyers asked this question in Q&A
Discussion options

You must be logged in to vote

You can't create async event handlers yet. This is planned but for now, you need to use spawn_local_scoped from inside a normal event handler.

    let submit_registration = |_| spawn_local_scoped(context, async move {
        if email_address.get().is_empty() || password.get().is_empty() {
            return;
        }
        let response = register_user(
            email_address.get().as_ref().clone(),
            password.get().as_ref().clone(),
        )
        .await
        .unwrap_or_default();
    });

Make sure you enable "suspense" feature on sycamore.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@seanpmyers
Comment options

@joeyame
Comment options

Answer selected by seanpmyers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants