wip: threadsafe

This commit is contained in:
Jonathan Kelley committed 2021-10-01 02:07:12 -04:00
1 parent 71f0df6374
commit 82953f2ac3
22 files changed
+414 -545

No files matched your search

+5 -7
View File
@@ -1,33 +1,31 @@
//! Tests for the lifecycle of components.
use std::{cell::RefCell, rc::Rc};
use anyhow::{Context, Result};
use dioxus::prelude::*;
use dioxus_core as dioxus;
use dioxus_core_macro::*;
use dioxus_html as dioxus_elements;
use std::sync::{Arc, Mutex};
mod test_logging;
const IS_LOGGING_ENABLED: bool = true;
type Shared<T> = Rc<RefCell<T>>;
type Shared<T> = Arc<Mutex<T>>;
#[test]
fn manual_diffing() {
test_logging::set_up_logging(IS_LOGGING_ENABLED);
#[derive(PartialEq, Props)]
struct AppProps {
value: Shared<&'static str>,
}
static App: FC<AppProps> = |cx, props| {
let val = props.value.borrow();
let val = props.value.lock().unwrap();
cx.render(rsx! { div { "{val}" } })
};
let value = Rc::new(RefCell::new("Hello"));
let value = Arc::new(Mutex::new("Hello"));
let mut dom = VirtualDom::new_with_props(
App,
AppProps {
@@ -37,7 +35,7 @@ fn manual_diffing() {
let _ = dom.rebuild();
*value.borrow_mut() = "goodbye";
*value.lock().unwrap() = "goodbye";
let edits = dom.diff();