yew_side_effect/
hooks.rs

1use yew::prelude::*;
2
3use crate::store::Store;
4use crate::SideEffects;
5
6pub(crate) type StoreCtx<T> = UseReducerHandle<Store<T>>;
7
8pub(crate) fn use_store<T>() -> Option<StoreCtx<T>>
9where
10    T: PartialEq + 'static,
11{
12    use_context::<UseReducerHandle<Store<T>>>()
13}
14
15/// A hook to read side effect.
16pub fn use_side_effects<T>() -> Option<SideEffects<T>>
17where
18    T: PartialEq + 'static,
19{
20    use_store::<T>().map(|m| m.get())
21}