fixed the bug when future restarts the state goes to ready instead of pending (#3617)
* fiexed the bug when future restarts the state goes to ready instead of pending * fix typo * Fix future and formatting --------- Co-authored-by: Evan Almloff <evanalmloff@gmail.com>
This commit is contained in:
1 parent
dfc359cdfb
commit
bdf87aadc7
1 file changed
+5
-2
@@ -29,12 +29,15 @@ where
|
|||||||
});
|
});
|
||||||
|
|
||||||
let cb = use_callback(move |_| {
|
let cb = use_callback(move |_| {
|
||||||
|
// Set the state to Pending when the task is restarted
|
||||||
|
state.set(UseResourceState::Pending);
|
||||||
|
|
||||||
// Create the user's task
|
// Create the user's task
|
||||||
let fut = rc.reset_and_run_in(&mut future);
|
let fut = rc.reset_and_run_in(&mut future);
|
||||||
|
|
||||||
// Spawn a wrapper task that polls the inner future and watch its dependencies
|
// Spawn a wrapper task that polls the inner future and watches its dependencies
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
// move the future here and pin it so we can poll it
|
// Move the future here and pin it so we can poll it
|
||||||
let fut = fut;
|
let fut = fut;
|
||||||
pin_mut!(fut);
|
pin_mut!(fut);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user