Evan Almloff 1 anno fa
parent
commit
05a6dda89c

+ 2 - 2
packages/hooks/tests/effect.rs

@@ -1,7 +1,7 @@
 #![allow(unused, non_upper_case_globals, non_snake_case)]
+use std::cell::RefCell;
 use std::collections::HashMap;
 use std::rc::Rc;
-use std::cell::RefCell;
 
 use dioxus::prelude::*;
 use dioxus_core::ElementId;
@@ -47,4 +47,4 @@ async fn effects_rerun() {
     let current_counter = counter.borrow();
     assert_eq!(current_counter.component, 1);
     assert_eq!(current_counter.effect, 1);
-}
+}

+ 1 - 1
packages/signals/Cargo.toml

@@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0"
 repository = "https://github.com/DioxusLabs/dioxus/"
 homepage = "https://dioxuslabs.com"
 keywords = ["dom", "ui", "gui", "react", "wasm"]
-rust-version = "1.60.0"
+rust-version = "1.64.0"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 

+ 2 - 4
packages/signals/src/copy_value.rs

@@ -86,11 +86,9 @@ fn current_owner<S: Storage<T>, T>() -> Owner<S> {
     }
 
     // Otherwise get the owner from the current reactive context.
-    match ReactiveContext::current(){
+    match ReactiveContext::current() {
         Some(current_reactive_context) => owner_in_scope(current_reactive_context.origin_scope()),
-        None => {
-            owner_in_scope(current_scope_id().expect("in a virtual dom"))
-        }
+        None => owner_in_scope(current_scope_id().expect("in a virtual dom")),
     }
 }
 

+ 5 - 3
packages/signals/src/reactive_context.rs

@@ -1,5 +1,5 @@
 use dioxus_core::prelude::{
-    current_scope_id, has_context, provide_context, schedule_update_any, ScopeId
+    current_scope_id, has_context, provide_context, schedule_update_any, ScopeId,
 };
 use generational_box::SyncStorage;
 use rustc_hash::FxHashSet;
@@ -77,7 +77,7 @@ impl ReactiveContext {
         }
 
         // If we're rendering, then try and use the reactive context attached to this component
-        if !dioxus_core::vdom_is_rendering(){
+        if !dioxus_core::vdom_is_rendering() {
             return None;
         }
         if let Some(cx) = has_context() {
@@ -85,7 +85,9 @@ impl ReactiveContext {
         }
 
         // Otherwise, create a new context at the current scope
-        Some(provide_context(ReactiveContext::new_for_scope(current_scope_id())))
+        Some(provide_context(ReactiveContext::new_for_scope(
+            current_scope_id(),
+        )))
     }
 
     /// Run this function in the context of this reactive context

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

@@ -201,7 +201,7 @@ impl<T, S: Storage<SignalData<T>>> Readable for Signal<T, S> {
     fn try_read(&self) -> Result<ReadableRef<Self>, generational_box::BorrowError> {
         let inner = self.inner.try_read()?;
 
-        if let Some(reactive_context) = ReactiveContext::current(){
+        if let Some(reactive_context) = ReactiveContext::current() {
             inner.subscribers.lock().unwrap().insert(reactive_context);
         }
 

+ 2 - 2
packages/signals/tests/create.rs

@@ -1,8 +1,8 @@
 #![allow(unused, non_upper_case_globals, non_snake_case)]
 
-use dioxus_core::NoOpMutations;
 use dioxus::prelude::*;
 use dioxus_core::ElementId;
+use dioxus_core::NoOpMutations;
 use dioxus_signals::*;
 
 #[test]
@@ -82,4 +82,4 @@ fn drop_signals() {
     fn create_without_cx() -> Signal<String> {
         Signal::new("hello world".to_string())
     }
-}
+}

+ 1 - 1
packages/signals/tests/memo.rs

@@ -143,4 +143,4 @@ fn memos_prevents_component_rerun() {
         assert_eq!(current_counter.component, 2);
         assert_eq!(current_counter.memo, 3);
     }
-}
+}

+ 1 - 1
packages/signals/tests/subscribe.rs

@@ -92,4 +92,4 @@ fn reading_subscribes() {
             assert_eq!(rerun_count, &2);
         }
     }
-}
+}