feat: massage lifetimes

This commit is contained in:
Jonathan Kelley committed 2021-10-16 17:37:28 -04:00
1 parent 16dbf4a6f8
commit 9726a065b0
92 files changed
+250 -241

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@
```rust, ignore
// An example Dioxus app - closely resembles React
static App: FC<()> = |cx, props| {
static App: FC<()> = |(cx, props)| {
let mut count = use_state(cx, || 0);
cx.render(rsx!(
+2 -2
View File
@@ -50,8 +50,8 @@ async fn ExampleLoader(cx: Context<()>) -> Vnode {
This API stores the result on the Context object, so the loaded data is taken as reference.
*/
let name: &Result<SomeStructure> = use_fetch_data("http://example.com/json", ())
.place_holder(|cx, props|rsx!{<div> "loading..." </div>})
.delayed_place_holder(1000, |cx, props|rsx!{ <div> "still loading..." </div>})
.place_holder(|(cx, props)|rsx!{<div> "loading..." </div>})
.delayed_place_holder(1000, |(cx, props)|rsx!{ <div> "still loading..." </div>})
.await;
match name {
+3 -3
View File
@@ -21,9 +21,9 @@ fn test() -> DomTree {
}
}
static TestComponent: FC<()> = |cx, props|html!{<div>"Hello world"</div>};
static TestComponent: FC<()> = |(cx, props)|html!{<div>"Hello world"</div>};
static TestComponent: FC<()> = |cx, props|{
static TestComponent: FC<()> = |(cx, props)|{
let g = "BLAH";
html! {
<div> "Hello world" </div>
@@ -31,7 +31,7 @@ static TestComponent: FC<()> = |cx, props|{
};
#[functional_component]
static TestComponent: FC<{ name: String }> = |cx, props|html! { <div> "Hello {name}" </div> };
static TestComponent: FC<{ name: String }> = |(cx, props)|html! { <div> "Hello {name}" </div> };
```
## Why this behavior?
+3 -3
View File
@@ -96,7 +96,7 @@ Sometimes you want a signal to propagate across your app, either through far-awa
```rust
const TITLE: Atom<String> = || "".to_string();
const Provider: FC<()> = |cx, props|{
const Provider: FC<()> = |(cx, props)|{
let title = use_signal(&cx, &TITLE);
rsx!(cx, input { value: title })
};
@@ -105,7 +105,7 @@ const Provider: FC<()> = |cx, props|{
If we use the `TITLE` atom in another component, we can cause updates to flow between components without calling render or diffing either component trees:
```rust
const Receiver: FC<()> = |cx, props|{
const Receiver: FC<()> = |(cx, props)|{
let title = use_signal(&cx, &TITLE);
log::info!("This will only be called once!");
rsx!(cx,
@@ -132,7 +132,7 @@ Dioxus automatically understands how to use your signals when mixed with iterato
```rust
const DICT: AtomFamily<String, String> = |_| {};
const List: FC<()> = |cx, props|{
const List: FC<()> = |(cx, props)|{
let dict = use_signal(&cx, &DICT);
cx.render(rsx!(
ul {
+3 -3
View File
@@ -85,7 +85,7 @@ fn main() {
dioxus::desktop::start(App, |c| c);
}
static App: FC<()> = |cx, props| {
static App: FC<()> = |(cx, props)| {
cx.render(rsx! (
div { "Hello, world!" }
))
@@ -111,7 +111,7 @@ fn main() {
Finally, our app. Every component in Dioxus is a function that takes in `Context` and `Props` and returns an `Option<VNode>`.
```rust
static App: FC<()> = |cx, props| {
static App: FC<()> = |(cx, props)| {
cx.render(rsx! {
div { "Hello, world!" }
})
@@ -149,7 +149,7 @@ If we wanted to golf a bit, we can shrink our hello-world even smaller:
```rust
fn main() {
static App: FC<()> = |cx, props| rsx!(cx, div {"hello world!"});
static App: FC<()> = |(cx, props)| rsx!(cx, div {"hello world!"});
dioxus::web::start(App, |c| c);
}
```