dioxus_signals/
lib.rs

1#![doc = include_str!("../README.md")]
2#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/79236386")]
3#![doc(html_favicon_url = "https://avatars.githubusercontent.com/u/79236386")]
4#![warn(missing_docs)]
5#![allow(clippy::type_complexity)]
6
7mod copy_value;
8pub use copy_value::*;
9
10pub(crate) mod signal;
11pub use signal::*;
12
13mod map;
14pub use map::*;
15
16mod map_mut;
17pub use map_mut::*;
18
19mod set_compare;
20pub use set_compare::*;
21
22mod memo;
23pub use memo::*;
24
25mod global;
26pub use global::*;
27
28mod impls;
29
30pub use generational_box::{
31    AnyStorage, BorrowError, BorrowMutError, Owner, Storage, SyncStorage, UnsyncStorage,
32};
33
34mod read;
35pub use read::*;
36
37mod write;
38pub use write::*;
39
40mod props;
41pub use props::*;
42
43pub mod warnings;
44
45mod boxed;
46pub use boxed::*;
47
48/// A macro to define extension methods for signal types that call the method with either `with` or `with_mut` depending on the mutability of self.
49macro_rules! ext_methods {
50    (
51        $(
52            $(#[$meta:meta])*
53            fn $name:ident $(<$($gen:tt),*>)? (&$($self:ident)+ $(, $arg_name:ident: $arg_type:ty )* ) $(-> $ret:ty)? = $expr:expr;
54        )*
55    ) => {
56        $(
57            $(#[$meta])*
58            #[track_caller]
59            fn $name$(<$($gen),*>)? (& $($self)+ $(, $arg_name: $arg_type )* ) $(-> $ret)?
60            {
61                ext_methods!(@with $($self)+, $($arg_name),*; $expr)
62            }
63        )*
64    };
65
66    (@with mut $self:ident, $($arg_name:ident),*; $expr:expr) => {
67        $self.with_mut(|_self| ($expr)(_self, $($arg_name),*))
68    };
69
70    (@with $self:ident, $($arg_name:ident),*; $expr:expr) => {
71        $self.with(|_self| ($expr)(_self, $($arg_name),*))
72    };
73}
74
75pub(crate) use ext_methods;