Make cx.spawn() return an Option<TaskId>, returns None if finished immediately

This commit is contained in:
kidkool850@gmail.com committed 2023-12-11 16:01:40 -06:00
1 parent 695bf009d1
commit 69ca1fd8a7
8 files changed
+38 -37

No files matched your search

+3 -8
View File
@@ -19,7 +19,8 @@ fn app(cx: Scope) -> Element {
emails_sent.write().push(message);
}
}
});
})
.unwrap();
cx.render(rsx! {
div {
@@ -27,13 +28,7 @@ fn app(cx: Scope) -> Element {
button {
onclick: move |_| {
let dom = VirtualDom::new_with_props(compose, ComposeProps {
app_tx: tx.clone()
});
// this returns a weak reference to the other window
// Be careful not to keep a strong reference to the other window or it will never be dropped
// and the window will never close.
let dom = VirtualDom::new_with_props(compose, ComposeProps { app_tx: tx.clone() });
window.new_window(dom, Default::default());
},
"Click to compose a new email"