Parcourir la source

wip: more examples

Jonathan Kelley il y a 4 ans
Parent
commit
891e366cd8
1 fichiers modifiés avec 0 ajouts et 77 suppressions
  1. 0 77
      examples/model.rs

+ 0 - 77
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<T> {
-        todo!()
-    }
-
-    trait ModelAble {
-        type Out;
-    }
-    fn make_model<F: ModelAble>(f: F) -> F::Out {
-        todo!()
-    }
-
-    // fn use_model(w: &mut ModelWrapper<MyModel>) {
-    //     let mut g1 = move || {
-    //         //
-    //         w.eat();
-    //     };
-    //     let mut g2 = move || {
-    //         //
-    //         w.eat();
-    //     };
-    //     g1();
-    //     g2();
-    // }
-
-    pub struct UseModel<T: Clone> {
-        real: T,
-        wip: RefCell<T>,
-    }
-
-    use std::cell::{Ref, RefMut};
-    impl<T: Clone> Deref for UseModel<T> {
-        type Target = T;
-
-        fn deref(&self) -> &Self::Target {
-            &self.real
-        }
-    }
-
-    impl<T: Clone> UseModel<T> {
-        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;
-        }
-    }
-}