fix signals in futures
This commit is contained in:
parent
a6f611eccf
commit
b3fbbba711
|
@ -33,12 +33,12 @@ struct ChildProps {
|
||||||
fn Child(cx: Scope<ChildProps>) -> Element {
|
fn Child(cx: Scope<ChildProps>) -> Element {
|
||||||
let count = cx.props.count;
|
let count = cx.props.count;
|
||||||
|
|
||||||
// use_future!(cx, || async move {
|
use_future!(cx, || async move {
|
||||||
// loop {
|
loop {
|
||||||
// tokio::time::sleep(std::time::Duration::from_secs(count.value())).await;
|
tokio::time::sleep(std::time::Duration::from_secs(count.value())).await;
|
||||||
// *count.write() += 1;
|
*count.write() += 1;
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
|
|
||||||
render! {
|
render! {
|
||||||
div {
|
div {
|
||||||
|
|
|
@ -17,6 +17,9 @@ impl VirtualDom {
|
||||||
|
|
||||||
let mut cx = Context::from_waker(&task.waker);
|
let mut cx = Context::from_waker(&task.waker);
|
||||||
|
|
||||||
|
// update the scope stack
|
||||||
|
self.runtime.scope_stack.borrow_mut().push(task.scope);
|
||||||
|
|
||||||
// If the task completes...
|
// If the task completes...
|
||||||
if task.task.borrow_mut().as_mut().poll(&mut cx).is_ready() {
|
if task.task.borrow_mut().as_mut().poll(&mut cx).is_ready() {
|
||||||
// Remove it from the scope so we dont try to double drop it when the scope dropes
|
// Remove it from the scope so we dont try to double drop it when the scope dropes
|
||||||
|
@ -26,5 +29,8 @@ impl VirtualDom {
|
||||||
// Remove it from the scheduler
|
// Remove it from the scheduler
|
||||||
tasks.try_remove(id.0);
|
tasks.try_remove(id.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove the scope from the stack
|
||||||
|
self.runtime.scope_stack.borrow_mut().pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue