|
@@ -2,13 +2,13 @@
|
|
|
|
|
|
Dioxus is an incredibly portable framework for UI development. The lessons, knowledge, hooks, and components you acquire over time can always be used for future projects. However, sometimes those projects cannot leverage a supported renderer or you need to implement your own better renderer.
|
|
|
|
|
|
-Great news: the design of the renderer is entirely up to you! We provide suggestions and inspiration with the 1st party renderers, but provide no trait or explicit interface to follow.
|
|
|
+Great news: the design of the renderer is entirely up to you! We provide suggestions and inspiration with the 1st party renderers, but only really require implementation of the `RealDom` trait for things to function properly.
|
|
|
|
|
|
## The specifics:
|
|
|
|
|
|
Implementing the renderer is fairly straightforward. The renderer needs to:
|
|
|
|
|
|
-1. Handle the stream of edit events generated by updates to the virtual DOM
|
|
|
+1. Handle the stream of edits generated by updates to the virtual DOM
|
|
|
2. Register listeners and pass events into the virtual DOM's event system
|
|
|
3. Progress the virtual DOM with an async executor (or disable the suspense API and use `progress_sync`)
|
|
|
|
|
@@ -31,14 +31,13 @@ pub trait RealDom {
|
|
|
fn append_child(&mut self);
|
|
|
fn replace_with(&mut self);
|
|
|
|
|
|
- // Remove Nodesfrom the dom
|
|
|
+ // Remove Nodes from the dom
|
|
|
fn remove(&mut self);
|
|
|
fn remove_all_children(&mut self);
|
|
|
|
|
|
// Create
|
|
|
fn create_text_node(&mut self, text: &str) -> RealDomNode;
|
|
|
- fn create_element(&mut self, tag: &str) -> RealDomNode;
|
|
|
- fn create_element_ns(&mut self, tag: &str, namespace: &str) -> RealDomNode;
|
|
|
+ fn create_element(&mut self, tag: &str, namespace: Option<&str>) -> RealDomNode;
|
|
|
|
|
|
// Events
|
|
|
fn new_event_listener(
|
|
@@ -166,3 +165,7 @@ cx.render(rsx!{
|
|
|
})
|
|
|
|
|
|
```
|
|
|
+
|
|
|
+## Conclusion
|
|
|
+
|
|
|
+That should be it! You should have nearly all the knowledge required on how to implement your own renderer. We're super interested in seeing Dioxus apps brought to custom desktop renderers, mobile renderer, video game UI, and even augmented reality! If you're interesting in contributing to any of the these projects, don't be afraid to reach out or join the community.
|