mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-22 00:28:28 +00:00
Fix error in examples/future.rs comments, use_futures inline docs comments, also added clarification that Signal<T>.read() and Singal<T>() are the same thing
This commit is contained in:
parent
5a73147d69
commit
70136b22ea
11 changed files with 164 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
|||
//! A simple example that shows how to use the use_future hook to run a background task.
|
||||
//!
|
||||
//! use_future assumes your future will never complete - it won't return a value.
|
||||
//! If you want to return a value, use use_resource instead.
|
||||
//! use_future won't return a value, analagous to use_effect.
|
||||
//! If you want to return a value from a future, use use_resource instead.
|
||||
|
||||
use dioxus::prelude::*;
|
||||
use std::time::Duration;
|
||||
|
|
22
examples/seven_guis/cells.rs
Normal file
22
examples/seven_guis/cells.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
//! The simplest example of a Dioxus app.
|
||||
//!
|
||||
//! In this example we:
|
||||
//! - import a number of important items from the prelude (launch, Element, rsx, div, etc.)
|
||||
//! - define a main function that calls the launch function with our app function
|
||||
//! - define an app function that returns a div element with the text "Hello, world!"
|
||||
//!
|
||||
//! The `launch` function is the entry point for all Dioxus apps. It takes a function that returns an Element. This function
|
||||
//! calls "launch" on the currently-configured renderer you have. So if the `web` feature is enabled, it will launch a web
|
||||
//! app, and if the `desktop` feature is enabled, it will launch a desktop app.
|
||||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
launch(app);
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
rsx! {
|
||||
div { "Hello, world!" }
|
||||
}
|
||||
}
|
22
examples/seven_guis/circle-drawer.rs
Normal file
22
examples/seven_guis/circle-drawer.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
//! The simplest example of a Dioxus app.
|
||||
//!
|
||||
//! In this example we:
|
||||
//! - import a number of important items from the prelude (launch, Element, rsx, div, etc.)
|
||||
//! - define a main function that calls the launch function with our app function
|
||||
//! - define an app function that returns a div element with the text "Hello, world!"
|
||||
//!
|
||||
//! The `launch` function is the entry point for all Dioxus apps. It takes a function that returns an Element. This function
|
||||
//! calls "launch" on the currently-configured renderer you have. So if the `web` feature is enabled, it will launch a web
|
||||
//! app, and if the `desktop` feature is enabled, it will launch a desktop app.
|
||||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
launch(app);
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
rsx! {
|
||||
div { "Hello, world!" }
|
||||
}
|
||||
}
|
25
examples/seven_guis/counter.rs
Normal file
25
examples/seven_guis/counter.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
//! The simplest example of a Dioxus app.
|
||||
//!
|
||||
//! In this example we:
|
||||
//! - import a number of important items from the prelude (launch, Element, rsx, div, etc.)
|
||||
//! - define a main function that calls the launch function with our app function
|
||||
//! - define an app function that returns a div element with the text "Hello, world!"
|
||||
//!
|
||||
//! The `launch` function is the entry point for all Dioxus apps. It takes a function that returns an Element. This function
|
||||
//! calls "launch" on the currently-configured renderer you have. So if the `web` feature is enabled, it will launch a web
|
||||
//! app, and if the `desktop` feature is enabled, it will launch a desktop app.
|
||||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
launch(app);
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
let counter = use_signal(|| 0usize);
|
||||
|
||||
rsx! {
|
||||
button { onclick: move || counter += 1, "Increment Counter" }
|
||||
p { "{counter}" }
|
||||
}
|
||||
}
|
22
examples/seven_guis/crud.rs
Normal file
22
examples/seven_guis/crud.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
//! The simplest example of a Dioxus app.
|
||||
//!
|
||||
//! In this example we:
|
||||
//! - import a number of important items from the prelude (launch, Element, rsx, div, etc.)
|
||||
//! - define a main function that calls the launch function with our app function
|
||||
//! - define an app function that returns a div element with the text "Hello, world!"
|
||||
//!
|
||||
//! The `launch` function is the entry point for all Dioxus apps. It takes a function that returns an Element. This function
|
||||
//! calls "launch" on the currently-configured renderer you have. So if the `web` feature is enabled, it will launch a web
|
||||
//! app, and if the `desktop` feature is enabled, it will launch a desktop app.
|
||||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
launch(app);
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
rsx! {
|
||||
div { "Hello, world!" }
|
||||
}
|
||||
}
|
22
examples/seven_guis/flight-booker.rs
Normal file
22
examples/seven_guis/flight-booker.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
//! The simplest example of a Dioxus app.
|
||||
//!
|
||||
//! In this example we:
|
||||
//! - import a number of important items from the prelude (launch, Element, rsx, div, etc.)
|
||||
//! - define a main function that calls the launch function with our app function
|
||||
//! - define an app function that returns a div element with the text "Hello, world!"
|
||||
//!
|
||||
//! The `launch` function is the entry point for all Dioxus apps. It takes a function that returns an Element. This function
|
||||
//! calls "launch" on the currently-configured renderer you have. So if the `web` feature is enabled, it will launch a web
|
||||
//! app, and if the `desktop` feature is enabled, it will launch a desktop app.
|
||||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
launch(app);
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
rsx! {
|
||||
div { "Hello, world!" }
|
||||
}
|
||||
}
|
22
examples/seven_guis/temperature-converter.rs
Normal file
22
examples/seven_guis/temperature-converter.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
//! The simplest example of a Dioxus app.
|
||||
//!
|
||||
//! In this example we:
|
||||
//! - import a number of important items from the prelude (launch, Element, rsx, div, etc.)
|
||||
//! - define a main function that calls the launch function with our app function
|
||||
//! - define an app function that returns a div element with the text "Hello, world!"
|
||||
//!
|
||||
//! The `launch` function is the entry point for all Dioxus apps. It takes a function that returns an Element. This function
|
||||
//! calls "launch" on the currently-configured renderer you have. So if the `web` feature is enabled, it will launch a web
|
||||
//! app, and if the `desktop` feature is enabled, it will launch a desktop app.
|
||||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
launch(app);
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
rsx! {
|
||||
div { "Hello, world!" }
|
||||
}
|
||||
}
|
22
examples/seven_guis/timer.rs
Normal file
22
examples/seven_guis/timer.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
//! The simplest example of a Dioxus app.
|
||||
//!
|
||||
//! In this example we:
|
||||
//! - import a number of important items from the prelude (launch, Element, rsx, div, etc.)
|
||||
//! - define a main function that calls the launch function with our app function
|
||||
//! - define an app function that returns a div element with the text "Hello, world!"
|
||||
//!
|
||||
//! The `launch` function is the entry point for all Dioxus apps. It takes a function that returns an Element. This function
|
||||
//! calls "launch" on the currently-configured renderer you have. So if the `web` feature is enabled, it will launch a web
|
||||
//! app, and if the `desktop` feature is enabled, it will launch a desktop app.
|
||||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
launch(app);
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
rsx! {
|
||||
div { "Hello, world!" }
|
||||
}
|
||||
}
|
|
@ -42,7 +42,7 @@ pub fn use_context<T: 'static + Clone>() -> T {
|
|||
/// use_context_provider(|| Signal::new(0));
|
||||
/// rsx! { Child {} }
|
||||
///}
|
||||
// This component does read from the signal, so when the signal changes it will rerun
|
||||
/// // This component does read from the signal, so when the signal changes it will rerun
|
||||
///#[component]
|
||||
///fn Child() -> Element {
|
||||
/// let signal: Signal<i32> = use_context();
|
||||
|
|
|
@ -12,7 +12,7 @@ use std::future::Future;
|
|||
/// This future will **not** run on the server
|
||||
/// The future is spawned on the next call to `flush_sync` which means that it will not run on the server.
|
||||
/// To run a future on the server, you should use `spawn` directly.
|
||||
/// `use_future` assumes your future will never complete - **it won't return a value**.
|
||||
/// `use_future` **won't return a value**.
|
||||
/// If you want to return a value, use `use_resource` instead.
|
||||
/// ```rust
|
||||
/// fn app() -> Element {
|
||||
|
|
|
@ -39,7 +39,9 @@ pub trait Readable {
|
|||
MappedSignal::new(try_read, peek)
|
||||
}
|
||||
|
||||
/// Get the current value of the state. If this is a signal, this will subscribe the current scope to the signal. If the value has been dropped, this will panic.
|
||||
/// Get the current value of the state. If this is a signal, this will subscribe the current scope to the signal.
|
||||
/// If the value has been dropped, this will panic. Calling this on a Signal is the same as
|
||||
/// using the signal() syntax to read and subscribe to its value
|
||||
#[track_caller]
|
||||
fn read(&self) -> ReadableRef<Self> {
|
||||
self.try_read().unwrap()
|
||||
|
|
Loading…
Add table
Reference in a new issue