dioxus_signals/global/
memo.rs1use super::{Global, InitializeFromFunction};
2use crate::read::Readable;
3use crate::read_impls;
4use crate::Memo;
5
6impl<T: PartialEq> InitializeFromFunction<T> for Memo<T> {
7 fn initialize_from_function(f: fn() -> T) -> Self {
8 Memo::new(f)
9 }
10}
11
12pub type GlobalMemo<T> = Global<Memo<T>, T>;
14
15impl<T: PartialEq + 'static> GlobalMemo<T> {
16 pub fn id(&self) -> generational_box::GenerationalBoxId {
18 self.resolve().id()
19 }
20
21 pub fn memo(&self) -> Memo<T> {
23 self.resolve()
24 }
25}
26
27read_impls!(GlobalMemo<T> where T: PartialEq);