Browse Source

fix effects

Evan Almloff 1 year ago
parent
commit
7daa945ae3
2 changed files with 5 additions and 3 deletions
  1. 1 1
      packages/signals/src/rt.rs
  2. 4 2
      packages/signals/tests/effect.rs

+ 1 - 1
packages/signals/src/rt.rs

@@ -143,7 +143,7 @@ impl<T: 'static, S: Storage<T>> CopyValue<T, S> {
 
     /// Set the value. If the value has been dropped, this will panic.
     pub fn set(&self, value: T) {
-        *self.write() = value;
+        self.value.set(value);
     }
 
     /// Run a function with a reference to the value. If the value has been dropped, this will panic.

+ 4 - 2
packages/signals/tests/effect.rs

@@ -6,8 +6,8 @@ use dioxus::prelude::*;
 use dioxus_core::ElementId;
 use dioxus_signals::*;
 
-#[test]
-fn effects_rerun() {
+#[tokio::test]
+async fn effects_rerun() {
     simple_logger::SimpleLogger::new().init().unwrap();
 
     #[derive(Default)]
@@ -40,6 +40,8 @@ fn effects_rerun() {
     );
 
     let _ = dom.rebuild().santize();
+    dom.render_with_deadline(tokio::time::sleep(std::time::Duration::from_millis(100)))
+        .await;
 
     let current_counter = counter.borrow();
     assert_eq!(current_counter.component, 1);