diff --git a/examples/counters/src/lib.rs b/examples/counters/src/lib.rs index 89d9da1b0..4b3a55e36 100644 --- a/examples/counters/src/lib.rs +++ b/examples/counters/src/lib.rs @@ -90,7 +90,7 @@ fn Counter( prop:value={let value = value.clone(); move || value().to_string()} on:input=input /> */ - //{move || value().to_string()} + {move || value().to_string()} diff --git a/leptos_dom/src/lib.rs b/leptos_dom/src/lib.rs index a5bf03ff8..9f40c6f8c 100644 --- a/leptos_dom/src/lib.rs +++ b/leptos_dom/src/lib.rs @@ -63,7 +63,7 @@ where }); } -pub fn create_component<'a, F, T>(cx: Scope, f: F) -> T +pub fn create_component(cx: Scope, f: F) -> T where F: Fn() -> T, T: IntoChild, diff --git a/leptos_reactive/Cargo.toml b/leptos_reactive/Cargo.toml index 80590906b..d2614c5e2 100644 --- a/leptos_reactive/Cargo.toml +++ b/leptos_reactive/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" log = "0.4" slotmap = { version = "1", features = ["serde"] } serde = { version = "1", features = ["derive"] } +debug-cell = "0.1" [target.'cfg(target_arch = "wasm32")'.dependencies] wasm-bindgen = "0.2" diff --git a/leptos_reactive/src/effect.rs b/leptos_reactive/src/effect.rs index 2128efd83..2458e118b 100644 --- a/leptos_reactive/src/effect.rs +++ b/leptos_reactive/src/effect.rs @@ -1,6 +1,9 @@ use crate::{Runtime, Scope, ScopeId, Source, Subscriber}; +use debug_cell::RefCell; use serde::{Deserialize, Serialize}; -use std::{any::type_name, cell::RefCell, collections::HashSet, fmt::Debug, marker::PhantomData}; +use std::{ + any::type_name, /* cell::RefCell, */ collections::HashSet, fmt::Debug, marker::PhantomData, +}; impl Scope { pub fn create_effect(self, f: impl FnMut(Option) -> T + 'static) -> Effect @@ -17,9 +20,9 @@ impl Scope { ty: PhantomData, }; - self.runtime - .any_effect((self.id, id), |effect| effect.run((self.id, id))); - + /* self.runtime + .any_effect((self.id, id), |effect| effect.run((self.id, id))); + */ eff } } @@ -92,8 +95,8 @@ where type_name::() ), ) - .field("value", &self.value) - .field("sources", &self.sources) + //.field("value", &self.value) + //.field("sources", &self.sources) .finish() } } diff --git a/leptos_reactive/src/scope.rs b/leptos_reactive/src/scope.rs index 158fd176c..5de406076 100644 --- a/leptos_reactive/src/scope.rs +++ b/leptos_reactive/src/scope.rs @@ -2,10 +2,11 @@ use crate::{ AnyEffect, AnyMemo, AnySignal, EffectId, EffectState, MemoId, MemoState, Runtime, SignalId, SignalState, }; +use debug_cell::RefCell; use slotmap::SlotMap; use std::{ any::{Any, TypeId}, - cell::RefCell, + /* cell::RefCell, */ collections::HashMap, fmt::Debug, }; @@ -90,7 +91,6 @@ impl Debug for ScopeDisposer { slotmap::new_key_type! { pub(crate) struct ScopeId; } -#[derive(Debug)] pub(crate) struct ScopeState { pub(crate) parent: Option, pub(crate) contexts: RefCell>>, @@ -100,6 +100,12 @@ pub(crate) struct ScopeState { pub(crate) effects: RefCell>>, } +impl Debug for ScopeState { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ScopeState").finish() + } +} + impl ScopeState { pub(crate) fn new(parent: Option) -> Self { Self { diff --git a/leptos_reactive/src/signal.rs b/leptos_reactive/src/signal.rs index fa96f6486..c108e3682 100644 --- a/leptos_reactive/src/signal.rs +++ b/leptos_reactive/src/signal.rs @@ -1,5 +1,6 @@ use crate::{Runtime, Scope, ScopeId, Source, Subscriber}; -use std::{any::Any, cell::RefCell, collections::HashSet, fmt::Debug, marker::PhantomData}; +use debug_cell::RefCell; +use std::{any::Any, /* cell::RefCell, */ collections::HashSet, fmt::Debug, marker::PhantomData,}; impl Scope { pub fn create_signal(self, value: T) -> (ReadSignal, WriteSignal) @@ -212,13 +213,26 @@ where slotmap::new_key_type! { pub(crate) struct SignalId; } -#[derive(Debug)] +//#[derive(Debug)] pub(crate) struct SignalState { value: RefCell, t_value: RefCell>, subscribers: RefCell>, } +impl Debug for SignalState +where + T: Debug, +{ + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("SignalState") + .field("value", &*self.value.borrow()) + .field("t_value", &*self.t_value.borrow()) + .field("subscribers", &*self.subscribers.borrow()) + .finish() + } +} + impl SignalState { pub fn new(value: T) -> Self { Self {