Wip
This commit is contained in:
1 parent
2eeb8f2386
commit
c809095124
3 files changed
+47
-27
No files matched your search
@@ -84,25 +84,14 @@ impl Scope {
|
|||||||
///
|
///
|
||||||
/// Props is ?Sized because we borrow the props and don't need to know the size. P (sized) is used as a marker (unsized)
|
/// Props is ?Sized because we borrow the props and don't need to know the size. P (sized) is used as a marker (unsized)
|
||||||
pub fn run_scope<'b>(&'b mut self) -> Result<()> {
|
pub fn run_scope<'b>(&'b mut self) -> Result<()> {
|
||||||
// pub fn run_scope<'bump>(&'bump mut self) -> Result<()> {
|
// cycle to the next frame and then reset it
|
||||||
// let frame = {
|
// this breaks any latent references
|
||||||
{
|
self.frames.next().bump.reset();
|
||||||
let frame = self.frames.next();
|
|
||||||
frame.bump.reset();
|
|
||||||
}
|
|
||||||
// frame
|
|
||||||
// };
|
|
||||||
// self.new_frame()
|
|
||||||
|
|
||||||
let ctx = Context {
|
let ctx = Context {
|
||||||
// arena: &self.hook_arena,
|
|
||||||
// hooks: &self.hooks,
|
|
||||||
// bump: &frame.bump,
|
|
||||||
idx: 0.into(),
|
idx: 0.into(),
|
||||||
_p: PhantomData {},
|
_p: PhantomData {},
|
||||||
scope: self,
|
scope: self,
|
||||||
// scope: self.myidx,
|
|
||||||
// listeners: &self.listeners,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let caller = self.caller.upgrade().expect("Failed to get caller");
|
let caller = self.caller.upgrade().expect("Failed to get caller");
|
||||||
@@ -118,14 +107,11 @@ impl Scope {
|
|||||||
- The VNode has a private API and can only be used from accessors.
|
- The VNode has a private API and can only be used from accessors.
|
||||||
- Public API cannot drop or destructure VNode
|
- Public API cannot drop or destructure VNode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let new_head = unsafe {
|
let new_head = unsafe {
|
||||||
// frame.head_node = unsafe {
|
// use the same type, just manipulate the lifetime
|
||||||
// // use the same type, just manipulate the lifetime
|
|
||||||
type ComComp<'c> = Rc<OpaqueComponent<'c>>;
|
type ComComp<'c> = Rc<OpaqueComponent<'c>>;
|
||||||
let caller = std::mem::transmute::<ComComp<'static>, ComComp<'b>>(caller);
|
let caller = std::mem::transmute::<ComComp<'static>, ComComp<'b>>(caller);
|
||||||
let r: DomTree = (caller.as_ref())(ctx);
|
(caller.as_ref())(ctx)
|
||||||
r
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.frames.cur_frame_mut().head_node = new_head.root;
|
self.frames.cur_frame_mut().head_node = new_head.root;
|
||||||
|
|||||||
@@ -229,3 +229,20 @@ impl UpdateFunnel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! UpdateFunnel {
|
||||||
|
(root: $root:expr) => {
|
||||||
|
VirtualDom::new($root)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// #[test]
|
||||||
|
// fn test_new_vdom() {
|
||||||
|
// let dom = UpdateFunnel! {
|
||||||
|
// root: |ctx, props| {
|
||||||
|
// ctx.render(rsx!{
|
||||||
|
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
// }
|
||||||
@@ -79,10 +79,12 @@ pub fn TodoList(ctx: Context, props: &()) -> DomTree {
|
|||||||
FilterState::Completed => item.checked,
|
FilterState::Completed => item.checked,
|
||||||
})
|
})
|
||||||
.map(|(id, item)| {
|
.map(|(id, item)| {
|
||||||
rsx!(TodoEntry {
|
TodoEntry!();
|
||||||
key: "{order}",
|
todo!()
|
||||||
item: item.clone()
|
// rsx!(TodoEntry {
|
||||||
})
|
// key: "{order}",
|
||||||
|
// item: item.clone()
|
||||||
|
// })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,9 +101,24 @@ pub struct TodoEntryProps {
|
|||||||
item: Rc<TodoItem>,
|
item: Rc<TodoItem>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn TodoEntry(ctx: Context, props: &TodoEntryProps) -> DomTree {
|
mod mac {
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! TodoEntry {
|
||||||
|
() => {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// pub fn TodoEntry(ctx: Context, props: &TodoEntryProps) -> DomTree {
|
||||||
|
// #[inline_props]
|
||||||
|
pub fn TodoEntry(
|
||||||
|
ctx: Context,
|
||||||
|
baller: &impl Fn() -> (),
|
||||||
|
caller: &impl Fn() -> (),
|
||||||
|
todo: &Rc<TodoItem>,
|
||||||
|
) -> DomTree {
|
||||||
|
// pub fn TodoEntry(ctx: Context, todo: &Rc<TodoItem>) -> DomTree {
|
||||||
let (is_editing, set_is_editing) = use_state(&ctx, || false);
|
let (is_editing, set_is_editing) = use_state(&ctx, || false);
|
||||||
let todo = &props.item;
|
// let todo = &props.item;
|
||||||
|
|
||||||
ctx.render(rsx! (
|
ctx.render(rsx! (
|
||||||
li {
|
li {
|
||||||
@@ -111,11 +128,11 @@ pub fn TodoEntry(ctx: Context, props: &TodoEntryProps) -> DomTree {
|
|||||||
type: "checkbox"
|
type: "checkbox"
|
||||||
"{todo.checked}"
|
"{todo.checked}"
|
||||||
}
|
}
|
||||||
{is_editing.then(|| rsx!(
|
{is_editing.then(|| rsx!{
|
||||||
input {
|
input {
|
||||||
value: "{contents}"
|
value: "{contents}"
|
||||||
}
|
}
|
||||||
))}
|
})}
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user