feat: read works on fermi root
This commit is contained in:
1 parent
eef0d7a4b5
commit
366a0a8026
1 file changed
+17
-2
@@ -95,7 +95,22 @@ impl AtomRoot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read<V>(&self, _f: impl Readable<V>) -> &V {
|
pub fn read<V: 'static>(&self, f: impl Readable<V>) -> Rc<V> {
|
||||||
todo!()
|
let mut atoms = self.atoms.borrow_mut();
|
||||||
|
|
||||||
|
// initialize the value if it's not already initialized
|
||||||
|
if let Some(slot) = atoms.get_mut(&f.unique_id()) {
|
||||||
|
slot.value.clone().downcast().unwrap()
|
||||||
|
} else {
|
||||||
|
let value = Rc::new(f.init());
|
||||||
|
atoms.insert(
|
||||||
|
f.unique_id(),
|
||||||
|
Slot {
|
||||||
|
value: value.clone(),
|
||||||
|
subscribers: HashSet::new(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user