added better documentation and code snipppets for the use_resource, use_future, use_effect and use_context hooks

This commit is contained in:
andrey committed 2024-02-27 10:36:05 +08:00
1 parent 24ebc1e628
commit 5a73147d69
3 files changed
+10 -7

No files matched your search

+4 -4
View File
@@ -8,17 +8,17 @@ use dioxus_signals::*;
use dioxus_signals::{Readable, Writable};
use std::future::Future;
/// A hook that allows you to spawn a future
///
/// A hook that allows you to spawn a 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` assumes your future will never complete - **it won't return a value**.
/// If you want to return a value, use `use_resource` instead.
/// ```rust
/// fn app() -> Element {
/// let mut count = use_signal(|| 0);
/// let mut running = use_signal(|| true);
/// // use_future will spawn an infinitely running future that can be started and stopped
/// // `use_future` will spawn an infinitely running future that can be started and stopped
/// use_future(move || async move {
/// loop {
/// if running() {