mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-01-08 18:59:01 +00:00
1.5 KiB
1.5 KiB
This module includes all life-cycle related mechanics, including the virtual DOM, scopes, properties, and lifecycles.
The VirtualDom is designed as so:
VDOM contains:
- An arena of component scopes.
- A scope contains
- lifecycle data
- hook data
- A scope contains
- Event queue
- An event
A VDOM is
- constructed from anything that implements "component"
A "Component" is anything (normally functions) that can be ran with a context to produce VNodes
- Must implement properties-builder trait which produces a properties builder
A Context
- Is a consumable struct
- Made of references to properties
- Holds a reference (lockable) to the underlying scope
- Is partially thread-safe
How to interact with the real dom?
idea: use only u32
pros:
- allows for 4,294,967,295 nodes (enough)
- u32 is relatively small
- doesn't add type noise
- allows virtualdom to stay completely generic
cons:
- cost of querying individual nodes (about 7ns per node query for all sizes w/ nohasher)
- old IDs need to be manually freed when subtrees are destroyed
- can be collected as garbage after every render
- loss of ids between renders........................
- each new render doesn't know which node the old one was connected to unless it is visited
- When are nodes not visited during diffing?
- They are predetermined to be removed (a parent was probed)
- something with keys?
- I think all nodes must be visited between diffs