dioxus/packages/core/src/debug_renderer.rs

46 lines
995 B
Rust
Raw Normal View History

2021-02-07 17:38:17 -05:00
//! Debug virtual doms!
//! This renderer comes built in with dioxus core and shows how to implement a basic renderer.
//!
//! Renderers don't actually need to own the virtual dom (it's up to the implementer).
2021-02-20 21:59:16 -05:00
use crate::prelude::VirtualDom;
2021-02-07 17:38:17 -05:00
pub struct DebugRenderer {
vdom: VirtualDom,
2021-02-07 17:38:17 -05:00
}
impl DebugRenderer {
pub fn new(vdom: VirtualDom) -> Self {
2021-02-07 17:38:17 -05:00
Self { vdom }
}
pub async fn run(&mut self) -> Result<(), ()> {
Ok(())
}
pub fn log_dom(&self) {}
}
#[cfg(old)]
2021-02-07 17:38:17 -05:00
#[cfg(test)]
mod tests {
use super::*;
use crate::prelude::*;
use crate::scope::Properties;
2021-02-07 17:38:17 -05:00
#[test]
fn ensure_creation() -> Result<(), ()> {
2021-03-07 21:28:20 -05:00
#[derive(PartialEq)]
struct Creation {}
impl FC for Creation {
fn render(ctx: Context, props: &Self) -> DomTree {
ctx.render(html! { <div>"hello world" </div> })
}
}
let mut dom = VirtualDom::new_with_props(Creation {});
2021-02-07 17:38:17 -05:00
Ok(())
}
}