wip: new approach at direct access to vdom
This commit starts the process of merging scope arena with the diff machine to give the diffing algorithm mutable access to components. React and Preact mutate the dom as they diff it which makes their implementations simpler and cleaner. The goal here is to give access of scopes to the diffing machine which can mutate the underyling representation during diffing.
This commit is contained in:
1 parent
424a18137f
commit
795a54a2e4
2 files changed
+15
-12
No files matched your search
@@ -32,7 +32,7 @@
|
||||
//!
|
||||
//! More info on how to improve this diffing algorithm:
|
||||
//! - https://hacks.mozilla.org/2019/03/fast-bump-allocated-virtual-doms-with-rust-and-wasm/
|
||||
use crate::innerlude::*;
|
||||
use crate::{arena::ScopeArena, innerlude::*};
|
||||
use bumpalo::Bump;
|
||||
use fxhash::{FxHashMap, FxHashSet};
|
||||
use generational_arena::Arena;
|
||||
@@ -62,6 +62,7 @@ pub struct DiffMachine<'a> {
|
||||
pub change_list: EditMachine<'a>,
|
||||
pub diffed: FxHashSet<ScopeIdx>,
|
||||
pub lifecycle_events: VecDeque<LifeCycleEvent<'a>>,
|
||||
pub vdom: ScopeArena,
|
||||
}
|
||||
pub enum LifeCycleEvent<'a> {
|
||||
Mount {
|
||||
@@ -97,8 +98,9 @@ fn get_id() -> u32 {
|
||||
}
|
||||
|
||||
impl<'a> DiffMachine<'a> {
|
||||
pub fn new() -> Self {
|
||||
pub fn new(vdom: ScopeArena) -> Self {
|
||||
Self {
|
||||
vdom,
|
||||
create_diffs: true,
|
||||
lifecycle_events: VecDeque::new(),
|
||||
change_list: EditMachine::new(),
|
||||
|
||||
Reference in new issue
Block a user