Improve inline docs (#2460)
Improve inline docs * improve incorrect event handler return error message * Improve event handler docs * document the eval functions * document spawn and common spawn errors * fix event handler docs * add notes about how you use attributes and elements in rsx * add doc aliases for attributes and events we rename * add some more aliases for common search terms * don't doc ignore any public examples in core * don't ignore public doc examples in ssr * don't ignore examples in the dioxus package readme * add a warning when you launch without a renderer enabled * fix some outdated element docs * add a bunch of examples to resource * add notes about desktop events * add more docs for use_resource * add on_unimplemented hint to Dependency * fix some unresolved links * add examples to each of the router traits * add not implemented errors for router traits * add an example to the routable trait * expand rsx macro docs * improve memo docs * update the dioxus readme * mention dioxus crate features in the docs * fix a bunch of doc tests * fix html doc tests * fix router doc tests * fix dioxus signals doc tests * fix dioxus ssr doc tests * fix use_future example in the hooks cheat sheet * add a javascript alias for eval * fix hook explanation values * remove unused embed-doc-image dependency
This commit is contained in:
1 parent
054351139f
commit
0127501dbf
71 files changed
+4132
-1162
No files matched your search
@@ -3,6 +3,14 @@ use dioxus_signals::{Readable, Writable};
|
||||
use crate::use_signal;
|
||||
|
||||
/// A dependency is a trait that can be used to determine if a effect or selector should be re-run.
|
||||
#[rustversion::attr(
|
||||
since(1.78.0),
|
||||
diagnostic::on_unimplemented(
|
||||
message = "`Dependency` is not implemented for `{Self}`",
|
||||
label = "Dependency",
|
||||
note = "Dependency is automatically implemented for all tuples with less than 8 references to element that implement `PartialEq` and `Clone`. For example, `(&A, &B, &C)` implements `Dependency` automatically as long as `A`, `B`, and `C` implement `PartialEq` and `Clone`.",
|
||||
)
|
||||
)]
|
||||
pub trait Dependency: Sized + Clone {
|
||||
/// The output of the dependency
|
||||
type Out: Clone + PartialEq + 'static;
|
||||
@@ -20,6 +28,14 @@ impl Dependency for () {
|
||||
}
|
||||
|
||||
/// A dependency is a trait that can be used to determine if a effect or selector should be re-run.
|
||||
#[rustversion::attr(
|
||||
since(1.78.0),
|
||||
diagnostic::on_unimplemented(
|
||||
message = "`DependencyElement` is not implemented for `{Self}`",
|
||||
label = "dependency element",
|
||||
note = "DependencyElement is automatically implemented for types that implement `PartialEq` and `Clone`",
|
||||
)
|
||||
)]
|
||||
pub trait DependencyElement: 'static + PartialEq + Clone {}
|
||||
impl<T> DependencyElement for T where T: 'static + PartialEq + Clone {}
|
||||
|
||||
@@ -83,6 +99,7 @@ impl_dep!(A = a1 a2, B = b1 b2, C = c1 c2, D = d1 d2, E = e1 e2, F = f1 f2, G =
|
||||
/// println!("Data changed: {}", data);
|
||||
/// }));
|
||||
/// ```
|
||||
#[doc = include_str!("../docs/rules_of_hooks.md")]
|
||||
pub fn use_reactive<O, D: Dependency>(
|
||||
non_reactive_data: D,
|
||||
mut closure: impl FnMut(D::Out) -> O + 'static,
|
||||
@@ -113,6 +130,7 @@ pub fn use_reactive<O, D: Dependency>(
|
||||
/// println!("Data changed: {}", data);
|
||||
/// }));
|
||||
/// ```
|
||||
#[doc = include_str!("../docs/rules_of_hooks.md")]
|
||||
#[macro_export]
|
||||
macro_rules! use_reactive {
|
||||
(|| $($rest:tt)*) => { use_reactive( (), move |_| $($rest)* ) };
|
||||
|
||||
Reference in new issue
Block a user