diff --git a/examples/model.rs b/examples/model.rs index 712aa1cc3..b7f63c601 100644 --- a/examples/model.rs +++ b/examples/model.rs @@ -162,80 +162,3 @@ fn CalculatorKey<'a, 'r>(cx: Context<'a, CalculatorKeyProps<'r>>) -> VNode<'a> { } }) } - -use odl::use_model; -mod odl { - use super::*; - use std::{ - cell::RefCell, - ops::{Deref, DerefMut}, - }; - /// Use model makes it easy to use "models" as state for components. To modify the model, call "modify" and a clone of the - /// current model will be made, with a RefMut lock on it. Dioxus will never run your components multithreaded, so you can - /// be relatively sure that this won't fail in practice - pub fn use_model<'a, T: Clone>(cx: &impl Scoped<'a>, f: impl FnOnce() -> T) -> &'a UseModel { - todo!() - } - - trait ModelAble { - type Out; - } - fn make_model(f: F) -> F::Out { - todo!() - } - - // fn use_model(w: &mut ModelWrapper) { - // let mut g1 = move || { - // // - // w.eat(); - // }; - // let mut g2 = move || { - // // - // w.eat(); - // }; - // g1(); - // g2(); - // } - - pub struct UseModel { - real: T, - wip: RefCell, - } - - use std::cell::{Ref, RefMut}; - impl Deref for UseModel { - type Target = T; - - fn deref(&self) -> &Self::Target { - &self.real - } - } - - impl UseModel { - pub fn new(t: T) -> Self { - Self { - real: t.clone(), - wip: RefCell::new(t), - } - } - pub fn get_mut(&self) -> RefMut<'_, T> { - self.wip.borrow_mut() - } - pub fn modify(&self, f: impl FnOnce(&mut T)) { - let mut g = self.get_mut(); - let r = g.deref_mut(); - todo!() - } - } - - #[derive(Clone, Copy)] - struct MyModel { - hunger: u32, - } - - impl MyModel { - fn eat(&mut self) { - self.hunger -= 1; - } - } -}