feat: task system works
but I broke the other things :(
This commit is contained in:
1 parent
84c3e9fcb1
commit
3a57b94262
12 files changed
+251
-181
No files matched your search
@@ -57,7 +57,7 @@ pub fn use_state<'a, 'c, T: 'static, F: FnOnce() -> T, P>(
|
||||
move || UseStateInner {
|
||||
current_val: initial_state_fn(),
|
||||
callback: cx.schedule_update(),
|
||||
wip: RefCell::new(None),
|
||||
wip: Rc::new(RefCell::new(None)),
|
||||
update_scheuled: Cell::new(false),
|
||||
},
|
||||
move |hook| {
|
||||
@@ -76,7 +76,7 @@ struct UseStateInner<T: 'static> {
|
||||
current_val: T,
|
||||
update_scheuled: Cell<bool>,
|
||||
callback: Rc<dyn Fn()>,
|
||||
wip: RefCell<Option<T>>,
|
||||
wip: Rc<RefCell<Option<T>>>,
|
||||
}
|
||||
|
||||
pub struct UseState<'a, T: 'static> {
|
||||
@@ -118,6 +118,11 @@ impl<'a, T: 'static> UseState<'a, T> {
|
||||
pub fn classic(self) -> (&'a T, &'a Rc<dyn Fn(T)>) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn setter(&self) -> Rc<dyn Fn(T)> {
|
||||
let slot = self.inner.wip.clone();
|
||||
Rc::new(move |new| *slot.borrow_mut() = Some(new))
|
||||
}
|
||||
}
|
||||
impl<'a, T: 'static + ToOwned<Owned = T>> UseState<'a, T> {
|
||||
pub fn get_mut(self) -> RefMut<'a, T> {
|
||||
|
||||
Reference in new issue
Block a user