wip: some project refactor
This commit is contained in:
1 parent
feab50f24a
commit
8cfc437bfe
27 files changed
+430
-677
No files matched your search
@@ -1,13 +1,15 @@
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
use std::{
|
||||
cell::{RefCell, RefMut},
|
||||
rc::Rc,
|
||||
vec::Drain,
|
||||
};
|
||||
|
||||
use crate::innerlude::*;
|
||||
|
||||
// We actually allocate the properties for components in their parent's properties
|
||||
// We then expose a handle to use those props for render in the form of "OpaqueComponent"
|
||||
pub type OpaqueComponent = dyn for<'b> Fn(&'b Scope) -> VNode<'b>;
|
||||
|
||||
#[derive(PartialEq, Debug, Clone, Default)]
|
||||
pub struct EventQueue(pub Rc<RefCell<Vec<HeightMarker>>>);
|
||||
pub struct EventQueue {
|
||||
pub queue: Rc<RefCell<Vec<HeightMarker>>>,
|
||||
}
|
||||
|
||||
impl EventQueue {
|
||||
pub fn new_channel(&self, height: u32, idx: ScopeIdx) -> Rc<dyn Fn()> {
|
||||
@@ -15,9 +17,17 @@ impl EventQueue {
|
||||
let marker = HeightMarker { height, idx };
|
||||
Rc::new(move || {
|
||||
log::debug!("channel updated {:#?}", marker);
|
||||
inner.0.as_ref().borrow_mut().push(marker)
|
||||
inner.queue.as_ref().borrow_mut().push(marker)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn sort_unstable(&self) {
|
||||
self.queue.borrow_mut().sort_unstable()
|
||||
}
|
||||
|
||||
pub fn borrow_mut(&self) -> RefMut<Vec<HeightMarker>> {
|
||||
self.queue.borrow_mut()
|
||||
}
|
||||
}
|
||||
|
||||
/// A helper type that lets scopes be ordered by their height
|
||||
@@ -39,6 +49,22 @@ impl PartialOrd for HeightMarker {
|
||||
}
|
||||
}
|
||||
|
||||
/// The `RealDomNode` is an ID handle that corresponds to a foreign DOM node.
|
||||
///
|
||||
/// "u64" was chosen for two reasons
|
||||
/// - 0 cost hashing
|
||||
/// - use with slotmap and other versioned slot arenas
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct RealDomNode(pub u64);
|
||||
impl RealDomNode {
|
||||
pub fn new(id: u64) -> Self {
|
||||
Self(id)
|
||||
}
|
||||
pub fn empty() -> Self {
|
||||
Self(u64::MIN)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DebugDom {
|
||||
counter: u64,
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user