chore: rename ctx to cx
This commit is contained in:
1 parent
23c14078bb
commit
81382e7044
99 files changed
+789
-664
No files matched your search
@@ -2,10 +2,10 @@ fn main() {}
|
||||
|
||||
use dioxus_core::prelude::*;
|
||||
|
||||
static Example: FC<()> = |ctx| {
|
||||
ctx.render(dioxus_core::prelude::LazyNodes::new(move |ctx| {
|
||||
let bump = ctx.bump();
|
||||
dioxus_core::builder::ElementBuilder::new(ctx, "h1")
|
||||
static Example: FC<()> = |cx| {
|
||||
cx.render(dioxus_core::prelude::LazyNodes::new(move |cx| {
|
||||
let bump = cx.bump();
|
||||
dioxus_core::builder::ElementBuilder::new(cx, "h1")
|
||||
.children([dioxus_core::builder::text3(bump, format_args!("hello"))])
|
||||
.finish()
|
||||
}))
|
||||
@@ -14,13 +14,13 @@ static Example: FC<()> = |ctx| {
|
||||
struct Props {
|
||||
text: String,
|
||||
}
|
||||
static Example2: FC<Props> = |ctx| {
|
||||
ctx.render(dioxus_core::prelude::LazyNodes::new(move |__ctx| {
|
||||
let bump = __ctx.bump();
|
||||
dioxus_core::builder::ElementBuilder::new(__ctx, "h1")
|
||||
static Example2: FC<Props> = |cx| {
|
||||
cx.render(dioxus_core::prelude::LazyNodes::new(move |__cx| {
|
||||
let bump = __cx.bump();
|
||||
dioxus_core::builder::ElementBuilder::new(__cx, "h1")
|
||||
.children([dioxus_core::builder::text3(
|
||||
bump,
|
||||
format_args!("{}", ctx.props.text),
|
||||
format_args!("{}", cx.props.text),
|
||||
)])
|
||||
.finish()
|
||||
}))
|
||||
|
||||
@@ -19,15 +19,15 @@ struct ListItem {
|
||||
age: u32,
|
||||
}
|
||||
|
||||
fn app(ctx: Context<AppProps>) -> VNode {
|
||||
let (val, set_val) = use_state(&ctx, || 0);
|
||||
fn app(cx: Context<AppProps>) -> VNode {
|
||||
let (val, set_val) = use_state(&cx, || 0);
|
||||
|
||||
ctx.render(LazyNodes::new(move |_nodectx| {
|
||||
builder::ElementBuilder::new(_nodectx, "div")
|
||||
cx.render(LazyNodes::new(move |_nodecx| {
|
||||
builder::ElementBuilder::new(_nodecx, "div")
|
||||
.iter_child({
|
||||
ctx.items.iter().map(|child| {
|
||||
cx.items.iter().map(|child| {
|
||||
builder::virtual_child(
|
||||
_nodectx,
|
||||
_nodecx,
|
||||
ChildItem,
|
||||
ChildProps {
|
||||
item: child.clone(),
|
||||
@@ -38,8 +38,8 @@ fn app(ctx: Context<AppProps>) -> VNode {
|
||||
)
|
||||
})
|
||||
})
|
||||
.iter_child([builder::ElementBuilder::new(_nodectx, "div")
|
||||
.iter_child([builder::text3(_nodectx.bump(), format_args!("{}", val))])
|
||||
.iter_child([builder::ElementBuilder::new(_nodecx, "div")
|
||||
.iter_child([builder::text3(_nodecx.bump(), format_args!("{}", val))])
|
||||
.finish()])
|
||||
.finish()
|
||||
}))
|
||||
|
||||
@@ -13,21 +13,21 @@ struct Props {
|
||||
static Example: FC<Props> = |cpt| {
|
||||
todo!()
|
||||
|
||||
// let value = ctx.use_context(|c: &SomeContext| c.items.last().unwrap());
|
||||
// let value = cx.use_context(|c: &SomeContext| c.items.last().unwrap());
|
||||
|
||||
// ctx.render(LazyNodes::new(move |bump| {
|
||||
// cx.render(LazyNodes::new(move |bump| {
|
||||
// builder::ElementBuilder::new(bump, "button")
|
||||
// .on("click", move |_| {
|
||||
// println!("Value is {}", ctx.name);
|
||||
// println!("Value is {}", cx.name);
|
||||
// println!("Value is {}", value.as_str());
|
||||
// println!("Value is {}", *value);
|
||||
// })
|
||||
// .on("click", move |_| {
|
||||
// println!("Value is {}", ctx.name);
|
||||
// println!("Value is {}", cx.name);
|
||||
// })
|
||||
// .finish()
|
||||
// }))
|
||||
// ctx.render(html! {
|
||||
// cx.render(html! {
|
||||
// <div>
|
||||
// <button onclick={move |_| println!("Value is {}", value)} />
|
||||
// <button onclick={move |_| println!("Value is {}", value)} />
|
||||
|
||||
@@ -34,7 +34,7 @@ fn main() {}
|
||||
// 2: Trees are not evaluated
|
||||
|
||||
// */
|
||||
// let example_caller = move |ctx: &Bump| {
|
||||
// let example_caller = move |cx: &Bump| {
|
||||
// todo!()
|
||||
// // let p = Props { blah: true, text };
|
||||
// // let c = Context { props: &p };
|
||||
@@ -57,11 +57,11 @@ fn main() {}
|
||||
// }
|
||||
// }
|
||||
|
||||
// fn component<'a>(ctx: Context<'a, Props>) -> VNode<'a> {
|
||||
// fn component<'a>(cx: Context<'a, Props>) -> VNode<'a> {
|
||||
// // Write asynchronous rendering code that immediately returns a "suspended" VNode
|
||||
// // The concurrent API will then progress this component when the future finishes
|
||||
// // You can suspend the entire component, or just parts of it
|
||||
// let product_list = ctx.suspend(async {
|
||||
// let product_list = cx.suspend(async {
|
||||
// // Suspend the rendering that completes when the future is done
|
||||
// match fetch_data().await {
|
||||
// Ok(data) => html! { <div> "success!" </div>},
|
||||
@@ -70,7 +70,7 @@ fn main() {}
|
||||
// });
|
||||
|
||||
// // todo!()
|
||||
// ctx.render(html! {
|
||||
// cx.render(html! {
|
||||
// <div>
|
||||
// <h1> "Products" </h1>
|
||||
// <button> "hello!" </button>
|
||||
@@ -82,27 +82,27 @@ fn main() {}
|
||||
// })
|
||||
// }
|
||||
|
||||
// fn BuilderComp<'a>(ctx: Context<'a, Props>) -> VNode<'a> {
|
||||
// fn BuilderComp<'a>(cx: Context<'a, Props>) -> VNode<'a> {
|
||||
// // VNodes can be constructed via a builder or the html! macro
|
||||
// // However, both of these are "lazy" - they need to be evaluated (aka, "viewed")
|
||||
// // We can "view" them with Context for ultimate speed while inside components
|
||||
// ctx.render(|bump| {
|
||||
// cx.render(|bump| {
|
||||
// div(bump)
|
||||
// .attr("class", "edit")
|
||||
// .child(text("Hello"))
|
||||
// .child(text(ctx.ctx.text.as_ref()))
|
||||
// .child(text(cx.cx.text.as_ref()))
|
||||
// .finish()
|
||||
// })
|
||||
// }
|
||||
|
||||
// #[fc]
|
||||
// fn EffcComp(ctx: Context, name: &str) -> VNode {
|
||||
// fn EffcComp(cx: Context, name: &str) -> VNode {
|
||||
// // VNodes can be constructed via a builder or the html! macro
|
||||
// // However, both of these are "lazy" - they need to be evaluated (aka, "viewed")
|
||||
// // We can "view" them with Context for ultimate speed while inside components
|
||||
// // use "phase" style allocation;
|
||||
|
||||
// ctx.render(html! {
|
||||
// cx.render(html! {
|
||||
// <div>
|
||||
// // your template goes here
|
||||
// // feel free to directly use "name"
|
||||
@@ -110,8 +110,8 @@ fn main() {}
|
||||
// })
|
||||
// }
|
||||
|
||||
// fn FullySuspended<'a>(ctx: &'a Context<Props>) -> VNode<'a> {
|
||||
// ctx.suspend(async {
|
||||
// fn FullySuspended<'a>(cx: &'a Context<Props>) -> VNode<'a> {
|
||||
// cx.suspend(async {
|
||||
// let i: i32 = 0;
|
||||
|
||||
// // full suspended works great with just returning VNodes!
|
||||
@@ -123,7 +123,7 @@ fn main() {}
|
||||
// _ => html! { <div> </div> },
|
||||
// };
|
||||
|
||||
// if ctx.ctx.blah {
|
||||
// if cx.cx.blah {
|
||||
// html! { <div> </div> }
|
||||
// } else {
|
||||
// tex
|
||||
|
||||
Reference in new issue
Block a user