dioxus/packages/core/architecture.md

58 lines
1.5 KiB
Markdown
Raw Normal View History

2021-02-07 22:38:17 +00:00
# This module includes all life-cycle related mechanics, including the virtual DOM, scopes, properties, and lifecycles.
2021-02-07 22:38:17 +00:00
---
2021-02-07 22:38:17 +00:00
The VirtualDom is designed as so:
VDOM contains:
2021-02-07 22:38:17 +00:00
- An arena of component scopes.
- A scope contains
- lifecycle data
- hook data
2021-02-07 22:38:17 +00:00
- Event queue
- An event
2021-02-07 22:38:17 +00:00
A VDOM is
2021-02-07 22:38:17 +00:00
- constructed from anything that implements "component"
A "Component" is anything (normally functions) that can be ran with a context to produce VNodes
2021-02-07 22:38:17 +00:00
- Must implement properties-builder trait which produces a properties builder
A Context
2021-02-07 22:38:17 +00:00
- 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
-
## idea: leak raw nodes and then reclaim them on drop
## idea: bind