wip: remove scopechildren in favor of elements directly

This commit is contained in:
Jonathan Kelley committed 2021-11-09 14:36:26 -05:00
1 parent b9fc5fc251
commit 574d7fdb9e
6 files changed
+153 -192

No files matched your search

+11 -18
View File
@@ -315,10 +315,7 @@ impl Scope {
/// rsx!(cx, div { "hello {state.0}" })
/// }
/// ```
pub fn provide_state<T>(&self, value: T)
where
T: 'static,
{
pub fn provide_state<T: 'static>(&self, value: T) {
self.shared_contexts
.borrow_mut()
.insert(TypeId::of::<T>(), Rc::new(value))
@@ -354,13 +351,20 @@ impl Scope {
/// # Example
///
/// ```rust
/// static App: FC<()> = |cx, props| {
/// fn App(cx: Context, props: &()) -> Element {
/// todo!();
/// rsx!(cx, div { "Subtree {id}"})
/// };
/// ```
pub fn create_subtree(&self) -> Option<u32> {
self.new_subtree()
if self.is_subtree_root.get() {
None
} else {
todo!()
// let cur = self.subtree().get();
// self.shared.cur_subtree.set(cur + 1);
// Some(cur)
}
}
/// Get the subtree ID that this scope belongs to.
@@ -371,7 +375,7 @@ impl Scope {
/// # Example
///
/// ```rust
/// static App: FC<()> = |cx, props| {
/// fn App(cx: Context, props: &()) -> Element {
/// let id = cx.get_current_subtree();
/// rsx!(cx, div { "Subtree {id}"})
/// };
@@ -492,17 +496,6 @@ impl Scope {
effect();
}
}
pub(crate) fn new_subtree(&self) -> Option<u32> {
todo!()
// if self.is_subtree_root.get() {
// None
// } else {
// let cur = self.shared.cur_subtree.get();
// self.shared.cur_subtree.set(cur + 1);
// Some(cur)
// }
}
}
pub struct BumpFrame {