wip: parity document
This commit is contained in:
1 parent
ee67654f58
commit
ba975410f9
7 files changed
+115
-51
No files matched your search
@@ -8,8 +8,8 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
dioxus-core = { path = "../core" }
|
||||
uuid = "0.8.2"
|
||||
|
||||
[dev-dependencies]
|
||||
uuid = { version = "0.8.2", features = ["v4"] }
|
||||
dioxus-web = { path = "../web" }
|
||||
wasm-bindgen-futures = "*"
|
||||
@@ -2,16 +2,22 @@ use std::collections::HashMap;
|
||||
|
||||
use dioxus_core::prelude::*;
|
||||
use recoil::*;
|
||||
use uuid::Uuid;
|
||||
|
||||
const TODOS: AtomFamily<&str, Todo> = |_| HashMap::new();
|
||||
const TODOS: AtomFamily<Uuid, Todo> = |_| HashMap::new();
|
||||
|
||||
#[derive(PartialEq)]
|
||||
struct Todo {
|
||||
checked: bool,
|
||||
title: String,
|
||||
contents: String,
|
||||
}
|
||||
|
||||
static App: FC<()> = |ctx, _| {
|
||||
use_init_recoil_root(ctx);
|
||||
|
||||
let todos = use_recoil_family(ctx, &TODOS);
|
||||
|
||||
rsx! { in ctx,
|
||||
div {
|
||||
"Basic Todolist with AtomFamilies in Recoil.rs"
|
||||
@@ -19,11 +25,20 @@ static App: FC<()> = |ctx, _| {
|
||||
}
|
||||
};
|
||||
|
||||
static Child: FC<()> = |ctx, _| {
|
||||
// let todo = use_recoil_value(ctx, &TODOS);
|
||||
#[derive(Props, PartialEq)]
|
||||
struct ChildProps {
|
||||
id: Uuid,
|
||||
}
|
||||
|
||||
static Child: FC<ChildProps> = |ctx, props| {
|
||||
let (todo, set_todo) = use_recoil_state(ctx, &TODOS.select(&props.id));
|
||||
|
||||
rsx! { in ctx,
|
||||
div {
|
||||
|
||||
h1 {"{todo.title}"}
|
||||
input { type: "checkbox", name: "scales", checked: "{todo.checked}" }
|
||||
label { "{todo.contents}", for: "scales" }
|
||||
p {"{todo.contents}"}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -18,8 +18,9 @@ const D_SELECTOR: SelectorFamilyBorrowed<i32, i32> = |api, key| -> &i32 {
|
||||
};
|
||||
|
||||
static App: FC<()> = |ctx, _| {
|
||||
let title = use_recoil_value(ctx, &C_SELECTOR);
|
||||
use_init_recoil_root(ctx);
|
||||
|
||||
let title = use_recoil_value(ctx, &C_SELECTOR);
|
||||
let title = "";
|
||||
rsx! { in ctx,
|
||||
div {
|
||||
|
||||
@@ -43,6 +43,7 @@ pub struct CollectionSelection<T> {
|
||||
_never: PhantomData<T>,
|
||||
}
|
||||
impl<T> Readable<T> for CollectionSelection<T> {}
|
||||
impl<T> Writeable<T> for CollectionSelection<T> {}
|
||||
|
||||
// =================
|
||||
// Selectors
|
||||
@@ -125,22 +126,26 @@ mod hooks {
|
||||
|
||||
pub fn use_set_state<'a, T: PartialEq>(
|
||||
c: Context<'a>,
|
||||
t: &'static impl Writeable<T>,
|
||||
t: &impl Writeable<T>,
|
||||
) -> &'a Rc<dyn Fn(T)> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn use_recoil_state<'a, T: PartialEq + 'static>(
|
||||
ctx: Context<'a>,
|
||||
readable: &'static impl Writeable<T>,
|
||||
writeable: &impl Writeable<T>,
|
||||
) -> (&'a T, &'a Rc<dyn Fn(T)>) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn use_recoil_value<'a, T: PartialEq>(
|
||||
pub fn use_recoil_value<'a, T: PartialEq>(ctx: Context<'a>, t: &impl Readable<T>) -> &'a T {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn use_recoil_family<'a, K, V, C: FamilyCollection<K, V>>(
|
||||
ctx: Context<'a>,
|
||||
t: &'static impl Readable<T>,
|
||||
) -> &'a T {
|
||||
t: &AtomFamily<K, V, C>,
|
||||
) -> &'a C {
|
||||
todo!()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user