Compare commits
2 Commits
main
...
diagnostic
Author | SHA1 | Date |
---|---|---|
Greg Johnston | d5ad8f5ae4 | |
Greg Johnston | 6b3e9cf85f |
|
@ -271,8 +271,9 @@ where
|
|||
let mut repr = ComponentRepr::new_with_id(name, id);
|
||||
|
||||
// disposed automatically when the parent scope is disposed
|
||||
let (child, _) = cx
|
||||
.run_child_scope(|cx| cx.untrack(|| children_fn(cx).into_view(cx)));
|
||||
let (child, _) = cx.run_child_scope(|cx| {
|
||||
cx.untrack_with_diagnostics(|| children_fn(cx).into_view(cx))
|
||||
});
|
||||
|
||||
repr.children.push(child);
|
||||
|
||||
|
|
|
@ -479,11 +479,17 @@ impl RuntimeId {
|
|||
instrument(level = "trace", skip_all,)
|
||||
)]
|
||||
#[inline(always)]
|
||||
pub(crate) fn untrack<T>(self, f: impl FnOnce() -> T) -> T {
|
||||
pub(crate) fn untrack<T>(
|
||||
self,
|
||||
f: impl FnOnce() -> T,
|
||||
diagnostics: bool,
|
||||
) -> T {
|
||||
with_runtime(self, |runtime| {
|
||||
let untracked_result;
|
||||
|
||||
SpecialNonReactiveZone::enter();
|
||||
if !diagnostics {
|
||||
SpecialNonReactiveZone::enter();
|
||||
}
|
||||
|
||||
let prev_observer =
|
||||
SetObserverOnDrop(self, runtime.observer.take());
|
||||
|
@ -493,7 +499,9 @@ impl RuntimeId {
|
|||
runtime.observer.set(prev_observer.1);
|
||||
std::mem::forget(prev_observer); // avoid Drop
|
||||
|
||||
SpecialNonReactiveZone::exit();
|
||||
if !diagnostics {
|
||||
SpecialNonReactiveZone::exit();
|
||||
}
|
||||
|
||||
untracked_result
|
||||
})
|
||||
|
@ -758,7 +766,7 @@ impl RuntimeId {
|
|||
cur_deps_value.replace(Some(deps_value.clone()));
|
||||
|
||||
let callback_value =
|
||||
Some(self.untrack(wrapped_callback.clone()));
|
||||
Some(self.untrack(wrapped_callback.clone(), false));
|
||||
|
||||
prev_callback_value.replace(callback_value);
|
||||
|
||||
|
|
|
@ -208,7 +208,14 @@ impl Scope {
|
|||
)]
|
||||
#[inline(always)]
|
||||
pub fn untrack<T>(&self, f: impl FnOnce() -> T) -> T {
|
||||
self.runtime.untrack(f)
|
||||
self.runtime.untrack(f, false)
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
/// Suspends reactive tracking but keeps the diagnostic warnings for
|
||||
/// untracked functions.
|
||||
pub fn untrack_with_diagnostics<T>(&self, f: impl FnOnce() -> T) -> T {
|
||||
self.runtime.untrack(f, true)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ use crate::{
|
|||
/// // setting name only causes name to log, not count
|
||||
/// set_name.set("Bob".into());
|
||||
/// ```
|
||||
#[track_caller]
|
||||
pub fn create_slice<T, O, S>(
|
||||
cx: Scope,
|
||||
signal: RwSignal<T>,
|
||||
|
@ -85,6 +86,7 @@ where
|
|||
|
||||
/// Takes a memoized, read-only slice of a signal. This is equivalent to the
|
||||
/// read-only half of [`create_slice`].
|
||||
#[track_caller]
|
||||
pub fn create_read_slice<T, O>(
|
||||
cx: Scope,
|
||||
signal: RwSignal<T>,
|
||||
|
@ -98,6 +100,7 @@ where
|
|||
|
||||
/// Creates a setter to access one slice of a signal. This is equivalent to the
|
||||
/// write-only half of [`create_slice`].
|
||||
#[track_caller]
|
||||
pub fn create_write_slice<T, O>(
|
||||
cx: Scope,
|
||||
signal: RwSignal<T>,
|
||||
|
|
Loading…
Reference in New Issue