wip: doesnt share on thread

This commit is contained in:
Jonathan Kelley committed 2021-05-27 17:57:59 -04:00
1 parent ba975410f9
commit fe67ff9fa4
32 files changed
+1008 -575

No files matched your search

+3 -3
View File
@@ -91,8 +91,8 @@ pub fn TodoList(ctx: Context, _props: &()) -> DomTree {
})
});
rsx! { in ctx,
div {
rsx! { in ctuse_read
div {use_read
header {
class: "header"
h1 {"todos"}
@@ -135,7 +135,7 @@ pub fn TodoEntry(ctx: Context, props: &TodoEntryProps) -> DomTree {
))}
}
))
}
}use_read
pub fn FilterToggles(ctx: Context, _props: &()) -> DomTree {
let reducer = use_recoil_callback(ctx, |api| TodoManager(api));
+7 -4
View File
@@ -2,7 +2,7 @@
//! --------------
//! This crate implements a renderer of the Dioxus Virtual DOM for the web browser using Websys.
use dioxus::prelude::Properties;
use dioxus::prelude::{Context, DomTree, Properties};
use fxhash::FxHashMap;
use web_sys::{window, Document, Element, Event, Node};
// use futures::{channel::mpsc, SinkExt, StreamExt};
@@ -33,7 +33,7 @@ impl WebsysRenderer {
///
/// Run the app to completion, panicing if any error occurs while rendering.
/// Pairs well with the wasm_bindgen async handler
pub async fn start(root: FC<()>) {
pub async fn start(root: impl for<'a> Fn(Context<'a>, &'a ()) -> DomTree + 'static) {
Self::new(root).run().await.expect("Virtual DOM failed :(");
}
@@ -41,7 +41,7 @@ impl WebsysRenderer {
///
/// This means that the root component must either consumes its own context, or statics are used to generate the page.
/// The root component can access things like routing in its context.
pub fn new(root: FC<()>) -> Self {
pub fn new(root: impl for<'a> Fn(Context<'a>, &'a ()) -> DomTree + 'static) -> Self {
Self::new_with_props(root, ())
}
@@ -49,7 +49,10 @@ impl WebsysRenderer {
/// Automatically progresses the creation of the VNode tree to completion.
///
/// A VDom is automatically created. If you want more granular control of the VDom, use `from_vdom`
pub fn new_with_props<T: Properties + 'static>(root: FC<T>, root_props: T) -> Self {
pub fn new_with_props<T: Properties + 'static>(
root: impl for<'a> Fn(Context<'a>, &'a T) -> DomTree + 'static,
root_props: T,
) -> Self {
Self::from_vdom(VirtualDom::new_with_props(root, root_props))
}