Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The future returned from the function passed into Action::new_local has an unnecessary(?) Send requirement #3309

Closed
rjmac opened this issue Dec 1, 2024 · 2 comments

Comments

@rjmac
Copy link
Contributor

rjmac commented Dec 1, 2024

Describe the bug

The signature of Action::new_local is

    pub fn new_local<F, Fu>(action_fn: F) -> Self
    where
        F: Fn(&I) -> Fu + 'static,
        Fu: Future<Output = O> + Send + 'static,

which makes this function less useful than it could be, since it means that all values held across await points must be Send. I don't think the Send requirement on the future is actually needed though? I forked leptos locally and removed it, and it still seems to compile and work properly.

Leptos Dependencies

leptos = { version = "0.7.0", features = ["csr"] }

Also checked my fork with the ssr feature in case there was a requirement for Sendness that only shows up when server-side rendering is enabled.

To Reproduce

Action::new_local(|()| async move {
  let x = Rc::new(0);
  futures_util::future::ready(()).await;
  *x
})

Expected behavior
This should compile.

Additional context
This came up in code ported from leptos 0.6, which has such a non-Send value being held across an await.

@gbj
Copy link
Collaborator

gbj commented Dec 1, 2024

Oh cool! If you forked it locally and it works would you like to make a quick PR?

@rjmac
Copy link
Contributor Author

rjmac commented Dec 1, 2024

Sure thing; created this PR

@benwis benwis closed this as completed in 6331b48 Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants