hooks/
lib.rs

1#![forbid(unsafe_code)]
2#![cfg_attr(all(feature = "futures-core", feature = "all", feature = "proc-macro"), doc = include_str!("../README.md"))]
3
4#[cfg(feature = "use_effect")]
5pub mod effect;
6
7#[cfg(feature = "use_effect")]
8pub use effect::effect_fn;
9
10#[cfg(feature = "use_mut")]
11pub mod hook_mut;
12
13#[cfg(feature = "use_memo")]
14pub mod memo;
15
16#[cfg(feature = "use_debug")]
17pub mod debug;
18
19#[cfg(feature = "use_default_pinned")]
20pub mod pinned;
21
22#[cfg(feature = "use_lazy_pinned")]
23pub mod lazy_pinned;
24
25#[cfg(feature = "use_lazy_pinned_hook")]
26pub mod lazy_pinned_hook;
27
28#[cfg(feature = "use_poll_next_update")]
29pub mod poll_next_update;
30
31#[cfg(feature = "ShareValue")]
32mod share_value;
33#[cfg(feature = "ShareValue")]
34pub use share_value::{ShareValue, ToOwnedShareValue};
35
36#[cfg(feature = "Signal")]
37mod signal;
38#[cfg(feature = "Signal")]
39pub use signal::{use_signal, Signal, SignalHook, ToOwnedSignal, UseSignal};
40
41#[cfg(feature = "use_shared_ref")]
42mod shared_ref;
43#[cfg(feature = "use_shared_ref")]
44pub use shared_ref::{
45    use_shared_ref, use_shared_ref_with, SharedRef, SharedRefUninitialized, UseSharedRef,
46    UseSharedRefWith,
47};
48
49#[cfg(feature = "use_shared_signal")]
50mod shared_signal;
51#[cfg(feature = "use_shared_signal")]
52pub use shared_signal::{
53    RefSharedSignalEq, SharedSignal, SharedSignalEq, UseSharedSignal,
54    UseSharedSignal as use_shared_signal, UseSharedSignalWith,
55    UseSharedSignalWith as use_shared_signal_with,
56};
57
58#[cfg(feature = "use_gen_ref")]
59mod gen_ref;
60#[cfg(feature = "use_gen_ref")]
61pub use gen_ref::{
62    GenRefKey, GenRefOwner, UseGenRef, UseGenRef as use_gen_ref, UseGenRefWith,
63    UseGenRefWith as use_gen_ref_with,
64};
65
66#[cfg(feature = "use_gen_signal")]
67mod gen_signal;
68#[cfg(feature = "use_gen_signal")]
69pub use gen_signal::{
70    GenSignal, GenSignalEq, GenSignalHook, GenSignalHookEq, UseGenSignal,
71    UseGenSignal as use_gen_signal, UseGenSignalWith, UseGenSignalWith as use_gen_signal_with,
72};
73
74#[cfg(feature = "use_state_with_updater")]
75mod state_with_updater;
76#[cfg(feature = "use_state_with_updater")]
77pub use state_with_updater::{
78    use_state_with_updater, use_state_with_updater_with, StateUpdater, StateWithUpdater,
79};
80
81#[cfg(feature = "UpdateState")]
82pub use state_with_updater::{IntoUpdateStateResult, UpdateState};
83
84#[cfg(feature = "use_shared_update_state")]
85pub use state_with_updater::{
86    use_shared_update_state, use_shared_update_state_with, SharedUpdateState, UseSharedUpdateState,
87    UseSharedUpdateStateWith,
88};
89
90#[cfg(feature = "use_gen_update_state")]
91pub use state_with_updater::{
92    use_gen_update_state, use_gen_update_state_with, GenUpdateStateKey, GenUpdateStateOwner,
93    UseGenUpdateState, UseGenUpdateStateWith,
94};
95
96#[cfg(any(feature = "use_shared_call", feature = "use_gen_call"))]
97pub use state_with_updater::Call;
98#[cfg(any(feature = "use_shared_set", feature = "use_gen_set"))]
99pub use state_with_updater::Set;
100#[cfg(any(feature = "use_shared_toggle", feature = "use_gen_toggle"))]
101pub use state_with_updater::Toggle;
102#[cfg(any(feature = "use_shared_reducer", feature = "use_gen_reducer"))]
103pub use state_with_updater::{Reduce, Reducer};
104
105#[cfg(feature = "use_shared_call")]
106pub use state_with_updater::{
107    use_shared_call, use_shared_call_with, SharedCall, UseSharedCall, UseSharedCallWith,
108};
109#[cfg(feature = "use_shared_reducer")]
110pub use state_with_updater::{
111    use_shared_reduce, use_shared_reduce_with, use_shared_reducer, use_shared_reducer_with,
112    SharedReduce, SharedReducer, UseSharedReduce, UseSharedReduceWith, UseSharedReducer,
113    UseSharedReducerWith,
114};
115#[cfg(feature = "use_shared_set")]
116pub use state_with_updater::{
117    use_shared_set, use_shared_set_with, SharedSet, UseSharedSet, UseSharedSetWith,
118};
119#[cfg(feature = "use_shared_toggle")]
120pub use state_with_updater::{
121    use_shared_toggle, use_shared_toggle_with, SharedToggle, UseSharedToggle, UseSharedToggleWith,
122};
123
124#[cfg(feature = "use_gen_call")]
125pub use state_with_updater::{
126    use_gen_call, use_gen_call_with, GenCallKey, GenCallOwner, UseGenCall, UseGenCallWith,
127};
128#[cfg(feature = "use_gen_reducer")]
129pub use state_with_updater::{
130    use_gen_reduce, use_gen_reduce_with, use_gen_reducer, use_gen_reducer_with, GenReduceKey,
131    GenReduceOwner, GenReducerKey, GenReducerOwner, UseGenReduce, UseGenReduceWith, UseGenReducer,
132    UseGenReducerWith,
133};
134#[cfg(feature = "use_gen_set")]
135pub use state_with_updater::{
136    use_gen_set, use_gen_set_with, GenSetKey, GenSetOwner, UseGenSet, UseGenSetWith,
137};
138#[cfg(feature = "use_gen_toggle")]
139pub use state_with_updater::{
140    use_gen_toggle, use_gen_toggle_with, GenToggleKey, GenToggleOwner, UseGenToggle,
141    UseGenToggleWith,
142};
143
144#[cfg(feature = "use_uninitialized_hook")]
145pub mod uninitialized_hook;
146
147mod signal_eq;
148pub use signal_eq::SignalEq;
149
150mod into_eq;
151pub use into_eq::IntoEq;
152
153pub mod local_key;
154
155pub mod prelude {
156    pub use hooks_core::prelude::*;
157
158    #[cfg(feature = "proc-macro")]
159    pub use hooks_macro::hook;
160
161    #[cfg(feature = "use_debug")]
162    pub use crate::debug::use_debug;
163    #[cfg(feature = "use_effect")]
164    pub use crate::effect::{
165        use_effect, use_effect_on_next_poll, use_effect_once, use_effect_once_with, use_effect_with,
166    };
167    #[cfg(feature = "use_mut")]
168    pub use crate::hook_mut::{use_mut, use_mut_default, use_mut_with};
169    #[cfg(feature = "use_lazy_pinned")]
170    pub use crate::lazy_pinned::{use_lazy_pinned, use_lazy_pinned_with};
171    #[cfg(feature = "use_lazy_pinned_hook")]
172    pub use crate::lazy_pinned_hook::use_lazy_pinned_hook;
173    #[cfg(feature = "use_memo")]
174    pub use crate::memo::use_memo;
175    #[cfg(feature = "use_default_pinned")]
176    pub use crate::pinned::use_default_pinned;
177    #[cfg(feature = "use_poll_next_update")]
178    pub use crate::poll_next_update::use_poll_next_update;
179    #[cfg(feature = "use_shared_ref")]
180    pub use crate::{use_shared_ref, use_shared_ref_with};
181    #[cfg(feature = "use_shared_signal")]
182    pub use crate::{use_shared_signal, use_shared_signal_with};
183
184    #[cfg(feature = "use_state_with_updater")]
185    pub use crate::{use_state_with_updater, use_state_with_updater_with};
186
187    #[cfg(feature = "use_shared_update_state")]
188    pub use crate::{use_shared_update_state, use_shared_update_state_with};
189
190    #[cfg(feature = "use_gen_update_state")]
191    pub use crate::{use_gen_update_state, use_gen_update_state_with};
192
193    #[cfg(feature = "use_shared_call")]
194    pub use crate::{use_shared_call, use_shared_call_with};
195    #[cfg(feature = "use_shared_reducer")]
196    pub use crate::{
197        use_shared_reduce, use_shared_reduce_with, use_shared_reducer, use_shared_reducer_with,
198    };
199    #[cfg(feature = "use_shared_set")]
200    pub use crate::{use_shared_set, use_shared_set_with};
201    #[cfg(feature = "use_shared_toggle")]
202    pub use crate::{use_shared_toggle, use_shared_toggle_with};
203
204    #[cfg(feature = "use_gen_call")]
205    pub use crate::{use_gen_call, use_gen_call_with};
206    #[cfg(feature = "use_gen_reducer")]
207    pub use crate::{use_gen_reduce, use_gen_reduce_with, use_gen_reducer, use_gen_reducer_with};
208    #[cfg(feature = "use_gen_set")]
209    pub use crate::{use_gen_set, use_gen_set_with};
210    #[cfg(feature = "use_gen_toggle")]
211    pub use crate::{use_gen_toggle, use_gen_toggle_with};
212
213    #[cfg(feature = "use_uninitialized_hook")]
214    pub use crate::uninitialized_hook::use_uninitialized_hook;
215
216    #[cfg(feature = "ShareValue")]
217    pub use crate::ShareValue;
218
219    #[cfg(feature = "Signal")]
220    pub use crate::{use_signal, Signal};
221
222    pub use crate::IntoEq;
223}
224
225pub use hooks_core as core;
226pub use hooks_core::{
227    hook_fn, impl_hook, Hook, HookExt, HookPollNextUpdate, HookPollNextUpdateExt, HookUnmount,
228    HookValue, IntoHook, UpdateHook, UpdateHookUninitialized, Value,
229};
230pub use prelude::*;
231
232pub(crate) mod utils;
233
234mod state_owner;