chore: rename ctx to cx

This commit is contained in:
Jonathan Kelley committed 2021-06-25 21:15:33 -04:00
1 parent 23c14078bb
commit 81382e7044
99 files changed
+789 -664

No files matched your search

+5 -5
View File
@@ -28,12 +28,12 @@ impl TitleController {
}
fn main() {
wasm_bindgen_futures::spawn_local(dioxus_web::WebsysRenderer::start(|ctx| {
let title = use_read(&ctx, &TITLE);
let subtitle = use_read(&ctx, &SUBTITLE);
let controller = TitleController::new(use_recoil_api(&ctx));
wasm_bindgen_futures::spawn_local(dioxus_web::WebsysRenderer::start(|cx| {
let title = use_read(&cx, &TITLE);
let subtitle = use_read(&cx, &SUBTITLE);
let controller = TitleController::new(use_recoil_api(&cx));
rsx! { in ctx,
rsx! { in cx,
div {
"{title}"
"{subtitle}"
+4 -4
View File
@@ -19,11 +19,11 @@ fn update_title(api: &RecoilApi) {
}
}
static App: FC<()> = |ctx| {
let title = use_read(&ctx, &TITLE);
let next_light = use_recoil_api(&ctx, |api| move |_| update_title(&api));
static App: FC<()> = |cx| {
let title = use_read(&cx, &TITLE);
let next_light = use_recoil_api(&cx, |api| move |_| update_title(&api));
rsx! { in ctx,
rsx! { in cx,
div {
"{title}"
button { onclick: {next_light}, "Next light" }
+4 -4
View File
@@ -31,13 +31,13 @@ const TODOS: EcsModel<u32, TodoModel> = |builder| {};
// const SELECT_TITLE: SelectorBorrowed<u32, &str> = |s, k| TODOS.field(0).select(k);
// const SELECT_SUBTITLE: SelectorBorrowed<u32, &str> = |s, k| TODOS.field(1).select(k);
static App: FC<()> = |ctx| {
use_init_recoil_root(ctx, |_| {});
static App: FC<()> = |cx| {
use_init_recoil_root(cx, |_| {});
// let title = use_recoil_value(ctx, &C_SELECTOR);
// let title = use_recoil_value(cx, &C_SELECTOR);
let title = "";
rsx! { in ctx,
rsx! { in cx,
div {
"{title}"
// button { onclick: {next_light}, "Next light" }
+8 -8
View File
@@ -13,18 +13,18 @@ struct Todo {
content: String,
}
static App: FC<()> = |ctx| {
use_init_recoil_root(ctx, move |cfg| {});
static App: FC<()> = |cx| {
use_init_recoil_root(cx, move |cfg| {});
let todos = use_read_family(ctx, &TODOS);
let todos = use_read_family(cx, &TODOS);
// rsx! { in ctx,
// rsx! { in cx,
// div {
// h1 {"Basic Todolist with AtomFamilies in Recoil.rs"}
// ul { { todos.keys().map(|id| rsx! { Child { id: *id } }) } }
// }
// }
ctx.render(html! {
cx.render(html! {
<a href="#" class="">
<img class="inline-block h-10 w-10 rounded-full object-cover ring-2 ring-white" src="/images/person/4.jpg" alt="Jade"/>
</a>
@@ -36,10 +36,10 @@ struct ChildProps {
id: Uuid,
}
static Child: FC<ChildProps> = |ctx| {
let (todo, set_todo) = use_read_write(ctx, &TODOS.select(&ctx.id));
static Child: FC<ChildProps> = |cx| {
let (todo, set_todo) = use_read_write(cx, &TODOS.select(&cx.id));
rsx! { in ctx,
rsx! { in cx,
li {
h1 {"{todo.title}"}
input { type: "checkbox", name: "scales", checked: "{todo.checked}" }
+8 -8
View File
@@ -12,11 +12,11 @@ struct Todo {
contents: String,
}
static App: FC<()> = |ctx| {
use_init_recoil_root(ctx, |_| {});
let todos = use_read(&ctx, &TODOS);
static App: FC<()> = |cx| {
use_init_recoil_root(cx, |_| {});
let todos = use_read(&cx, &TODOS);
rsx! { in ctx,
rsx! { in cx,
div {
"Basic Todolist with AtomFamilies in Recoil.rs"
}
@@ -28,11 +28,11 @@ struct ChildProps {
id: Uuid,
}
static Child: FC<ChildProps> = |ctx| {
let todo = use_read(ctx, &TODOS).get(&ctx.id).unwrap();
// let (todo, set_todo) = use_read_write(ctx, &TODOS);
static Child: FC<ChildProps> = |cx| {
let todo = use_read(cx, &TODOS).get(&cx.id).unwrap();
// let (todo, set_todo) = use_read_write(cx, &TODOS);
rsx! { in ctx,
rsx! { in cx,
div {
h1 {"{todo.title}"}
input { type: "checkbox", name: "scales", checked: "{todo.checked}" }
+4 -4
View File
@@ -3,12 +3,12 @@ use recoil::*;
const COUNT: Atom<i32> = |_| 0;
static App: FC<()> = |ctx| {
use_init_recoil_root(ctx, |_| {});
static App: FC<()> = |cx| {
use_init_recoil_root(cx, |_| {});
let (count, set_count) = use_read_write(&ctx, &COUNT);
let (count, set_count) = use_read_write(&cx, &COUNT);
rsx! { in ctx,
rsx! { in cx,
div {
"Count: {count}"
br {}
+4 -4
View File
@@ -17,12 +17,12 @@ const D_SELECTOR: SelectorFamilyBorrowed<i32, i32> = |api, key| -> &i32 {
a
};
static App: FC<()> = |ctx| {
use_init_recoil_root(ctx, |_| {});
static App: FC<()> = |cx| {
use_init_recoil_root(cx, |_| {});
let title = use_read(ctx, &C_SELECTOR);
let title = use_read(cx, &C_SELECTOR);
rsx! { in ctx,
rsx! { in cx,
div {
"{title}"
// button { onclick: {next_light}, "Next light" }
+12 -12
View File
@@ -5,9 +5,9 @@ const A: Atom<i32> = |_| 0;
const B: Atom<i32> = |_| 0;
const C: Selector<i32> = |api| api.get(&A) + api.get(&B);
static App: FC<()> = |ctx| {
use_init_recoil_root(ctx, |_| {});
rsx! { in ctx,
static App: FC<()> = |cx| {
use_init_recoil_root(cx, |_| {});
rsx! { in cx,
div {
Banner {}
BtnA {}
@@ -16,14 +16,14 @@ static App: FC<()> = |ctx| {
}
};
static Banner: FC<()> = |ctx| {
let count = use_read(&ctx, &C);
ctx.render(rsx! { h1 { "Count: {count}" } })
static Banner: FC<()> = |cx| {
let count = use_read(&cx, &C);
cx.render(rsx! { h1 { "Count: {count}" } })
};
static BtnA: FC<()> = |ctx| {
let (a, set) = use_read_write(&ctx, &A);
rsx! { in ctx,
static BtnA: FC<()> = |cx| {
let (a, set) = use_read_write(&cx, &A);
rsx! { in cx,
div { "a"
button { "+", onclick: move |_| set(a + 1) }
button { "-", onclick: move |_| set(a - 1) }
@@ -31,9 +31,9 @@ static BtnA: FC<()> = |ctx| {
}
};
static BtnB: FC<()> = |ctx| {
let (b, set) = use_read_write(&ctx, &B);
rsx! { in ctx,
static BtnB: FC<()> = |cx| {
let (b, set) = use_read_write(&cx, &B);
rsx! { in cx,
div { "b"
button { "+", onclick: move |_| set(b + 1) }
button { "-", onclick: move |_| set(b - 1) }
+1 -1
View File
@@ -2,7 +2,7 @@ fn main() {}
use dioxus_core::prelude::*;
static App: FC<()> = |ctx| {
static App: FC<()> = |cx| {
//
use_initialize_app()
};
@@ -13,23 +13,23 @@ use std::future::Future;
use dioxus_core::prelude::*;
static App: FC<()> = |ctx| {
static App: FC<()> = |cx| {
//
let title = use_async_atom();
let title_card = suspend(&ctx, title, move |val| {
let title_card = suspend(&cx, title, move |val| {
//
rsx!(in ctx, div {
rsx!(in cx, div {
h3 { "{val}" }
})
});
// let fut = (use_async_atom(), use_async_atom());
// let title_card2 = ctx.suspend(fut, move |(text, text2)| {
// ctx.render(rsx!( h3 { "{text}" } ))
// let title_card2 = cx.suspend(fut, move |(text, text2)| {
// cx.render(rsx!( h3 { "{text}" } ))
// });
ctx.render(rsx! {
cx.render(rsx! {
div {
{title_card}
// {title_card2}