wip: major cleanups to scheduler
This commit is contained in:
1 parent
d96276a715
commit
2933e4bc11
36 files changed
+641
-663
No files matched your search
@@ -82,13 +82,6 @@ pub fn use_shared_state<'a, T: 'static>(cx: Context<'a>) -> Option<UseSharedStat
|
||||
_ => None,
|
||||
}
|
||||
},
|
||||
|f| {
|
||||
// we need to unsubscribe when our component is unounted
|
||||
if let Some(root) = &f.root {
|
||||
let mut root = root.borrow_mut();
|
||||
root.consumers.remove(&f.scope_id);
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -98,6 +91,15 @@ struct SharedStateInner<T: 'static> {
|
||||
scope_id: ScopeId,
|
||||
needs_notification: Cell<bool>,
|
||||
}
|
||||
impl<T> Drop for SharedStateInner<T> {
|
||||
fn drop(&mut self) {
|
||||
// we need to unsubscribe when our component is unounted
|
||||
if let Some(root) = &self.root {
|
||||
let mut root = root.borrow_mut();
|
||||
root.consumers.remove(&self.scope_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UseSharedState<'a, T: 'static> {
|
||||
pub(crate) cx: Context<'a>,
|
||||
@@ -172,6 +174,5 @@ pub fn use_provide_state<'a, T: 'static>(cx: Context<'a>, f: impl FnOnce() -> T)
|
||||
cx.provide_state(state)
|
||||
},
|
||||
|inner| {},
|
||||
|_| {},
|
||||
)
|
||||
}
|
||||
@@ -16,7 +16,6 @@ pub fn use_ref<T: 'static>(cx: Context, f: impl FnOnce() -> T) -> UseRef<T> {
|
||||
inner.update_scheuled.set(false);
|
||||
UseRef { inner }
|
||||
},
|
||||
|_| {},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,6 @@ pub fn use_state<'a, T: 'static>(
|
||||
|
||||
UseState { inner: &*hook }
|
||||
},
|
||||
|_| {},
|
||||
)
|
||||
}
|
||||
struct UseStateInner<T: 'static> {
|
||||
|
||||
Reference in new issue
Block a user