Prechádzať zdrojové kódy

remove signal write warnings (#4024)

Evan Almloff 2 mesiacov pred
rodič
commit
d857629115

+ 1 - 6
packages/devtools/src/lib.rs

@@ -1,7 +1,6 @@
 use dioxus_core::{ScopeId, VirtualDom};
 use dioxus_core::{ScopeId, VirtualDom};
 pub use dioxus_devtools_types::*;
 pub use dioxus_devtools_types::*;
 use dioxus_signals::{GlobalKey, Writable};
 use dioxus_signals::{GlobalKey, Writable};
-use warnings::Warning;
 
 
 /// Applies template and literal changes to the VirtualDom
 /// Applies template and literal changes to the VirtualDom
 ///
 ///
@@ -19,11 +18,7 @@ pub fn apply_changes(dom: &VirtualDom, msg: &HotReloadMsg) {
                 index: template.key.index as _,
                 index: template.key.index as _,
             };
             };
             if let Some(mut signal) = ctx.get_signal_with_key(key.clone()) {
             if let Some(mut signal) = ctx.get_signal_with_key(key.clone()) {
-                dioxus_signals::warnings::signal_read_and_write_in_reactive_scope::allow(|| {
-                    dioxus_signals::warnings::signal_write_in_component_body::allow(|| {
-                        signal.set(Some(value));
-                    });
-                });
+                signal.set(Some(value));
             }
             }
         }
         }
     });
     });

+ 1 - 8
packages/hooks/src/use_reactive.rs

@@ -110,14 +110,7 @@ pub fn use_reactive<O, D: Dependency>(
         non_reactive_data.out()
         non_reactive_data.out()
     });
     });
     if !first_run && non_reactive_data.changed(&*last_state.peek()) {
     if !first_run && non_reactive_data.changed(&*last_state.peek()) {
-        use warnings::Warning;
-        // In use_reactive we do read and write to a signal during rendering to bridge the reactive and non-reactive worlds.
-        // We ignore
-        dioxus_signals::warnings::signal_read_and_write_in_reactive_scope::allow(|| {
-            dioxus_signals::warnings::signal_write_in_component_body::allow(|| {
-                last_state.set(non_reactive_data.out())
-            })
-        });
+        last_state.set(non_reactive_data.out())
     }
     }
     move || closure(last_state())
     move || closure(last_state())
 }
 }

+ 1 - 5
packages/signals/src/memo.rs

@@ -1,4 +1,3 @@
-use crate::warnings::{signal_read_and_write_in_reactive_scope, signal_write_in_component_body};
 use crate::write::Writable;
 use crate::write::Writable;
 use crate::{read::Readable, ReadableRef, Signal};
 use crate::{read::Readable, ReadableRef, Signal};
 use crate::{read_impls, GlobalMemo};
 use crate::{read_impls, GlobalMemo};
@@ -12,7 +11,6 @@ use std::{
 use dioxus_core::prelude::*;
 use dioxus_core::prelude::*;
 use futures_util::StreamExt;
 use futures_util::StreamExt;
 use generational_box::{AnyStorage, BorrowResult, UnsyncStorage};
 use generational_box::{AnyStorage, BorrowResult, UnsyncStorage};
-use warnings::Warning;
 
 
 struct UpdateInformation<T> {
 struct UpdateInformation<T> {
     dirty: Arc<AtomicBool>,
     dirty: Arc<AtomicBool>,
@@ -181,9 +179,7 @@ where
         let result = if needs_update {
         let result = if needs_update {
             drop(read);
             drop(read);
             // We shouldn't be subscribed to the value here so we don't trigger the scope we are currently in to rerun even though that scope got the latest value because we synchronously update the value: https://github.com/DioxusLabs/dioxus/issues/2416
             // We shouldn't be subscribed to the value here so we don't trigger the scope we are currently in to rerun even though that scope got the latest value because we synchronously update the value: https://github.com/DioxusLabs/dioxus/issues/2416
-            signal_read_and_write_in_reactive_scope::allow(|| {
-                signal_write_in_component_body::allow(|| self.recompute())
-            });
+            self.recompute();
             self.inner.inner.try_read_unchecked()
             self.inner.inner.try_read_unchecked()
         } else {
         } else {
             Ok(read)
             Ok(read)

+ 1 - 6
packages/signals/src/read_only_signal.rs

@@ -55,12 +55,7 @@ impl<T: 'static, S: Storage<SignalData<T>>> ReadOnlySignal<T, S> {
     /// Mark any readers of the signal as dirty
     /// Mark any readers of the signal as dirty
     pub fn mark_dirty(&mut self) {
     pub fn mark_dirty(&mut self) {
         use crate::write::Writable;
         use crate::write::Writable;
-        use warnings::Warning;
-        // We diff props while rendering, but we only write to the signal if it has
-        // changed so it is safe to ignore the warning
-        crate::warnings::signal_write_in_component_body::allow(|| {
-            _ = self.inner.try_write();
-        });
+        _ = self.inner.try_write();
     }
     }
 }
 }
 
 

+ 0 - 5
packages/signals/src/signal.rs

@@ -692,11 +692,6 @@ impl<T: 'static, S: Storage<SignalData<T>>> Drop for SignalSubscriberDrop<T, S>
                 "Write on signal at {} finished, updating subscribers",
                 "Write on signal at {} finished, updating subscribers",
                 self.origin
                 self.origin
             );
             );
-            crate::warnings::signal_write_in_component_body(self.origin);
-            crate::warnings::signal_read_and_write_in_reactive_scope::<T, S>(
-                self.origin,
-                self.signal,
-            );
         }
         }
         self.signal.update_subscribers();
         self.signal.update_subscribers();
     }
     }