yew/functional/hooks/
mod.rsmod use_callback;
mod use_context;
mod use_effect;
mod use_force_update;
mod use_memo;
mod use_prepared_state;
mod use_reducer;
mod use_ref;
mod use_state;
mod use_transitive_state;
pub use use_callback::*;
pub use use_context::*;
pub use use_effect::*;
pub use use_force_update::*;
pub use use_memo::*;
pub use use_prepared_state::*;
pub use use_reducer::*;
pub use use_ref::*;
pub use use_state::*;
pub use use_transitive_state::*;
use crate::functional::HookContext;
pub trait Hook {
type Output;
fn run(self, ctx: &mut HookContext) -> Self::Output;
}
#[doc(hidden)]
#[allow(missing_debug_implementations, missing_docs)]
pub struct BoxedHook<'hook, T> {
inner: Box<dyn 'hook + FnOnce(&mut HookContext) -> T>,
}
impl<'hook, T> BoxedHook<'hook, T> {
#[allow(missing_docs)]
pub fn new(inner: Box<dyn 'hook + FnOnce(&mut HookContext) -> T>) -> Self {
Self { inner }
}
}
impl<T> Hook for BoxedHook<'_, T> {
type Output = T;
fn run(self, ctx: &mut HookContext) -> Self::Output {
(self.inner)(ctx)
}
}