We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
TLDR; When several calls of Action are pending, pending() is set to false on the first finished task.
While reading through the sources, I've found out this oddly looking line:
leptos/leptos_server/src/action.rs
Line 395 in c53fc67
#[component] pub fn App() -> impl IntoView { let action = create_action(|v: &i32| { let v = *v; async move { gloo_timers::future::sleep(std::time::Duration::from_secs(4)).await; v + 1 } }); spawn_local(async move { action.dispatch(10); gloo_timers::future::sleep(std::time::Duration::from_secs(2)).await; action.dispatch(41); }); view! { <div class="container"> <h1>"Computation"</h1> <span>"Computation result: " {action.value()}</span> <span> { move || if action.pending()() { "Loading..." } else { "" } } </span> </div> } }
After the action.value() becomes 11, the "Loading..." text disappears and only after 2 seconds the action.value() becomes 42.
action.value()
I've prepared PR, that fixes this.
Leptos Dependencies N/A
To Reproduce See above
Expected behavior action.pending() to represent pending state of an Action
action.pending()
Action
Screenshots N/A
Additional context N/A
The text was updated successfully, but these errors were encountered:
Fix of #leptos-rs#2652
a368f97
No branches or pull requests
TLDR;
When several calls of Action are pending, pending() is set to false on the first finished task.
While reading through the sources, I've found out this oddly looking line:
leptos/leptos_server/src/action.rs
Line 395 in c53fc67
Which decreases pending count instead of increasing it. CSR example below showcases this bug:
After the
action.value()
becomes 11, the "Loading..." text disappears and only after 2 seconds theaction.value()
becomes 42.I've prepared PR, that fixes this.
Leptos Dependencies
N/A
To Reproduce
See above
Expected behavior
action.pending()
to represent pending state of anAction
Screenshots
N/A
Additional context
N/A
The text was updated successfully, but these errors were encountered: