Any recommendations on debugging signal-based code? #515
Replies: 2 comments 7 replies
-
You can see which signals a component is subscribed to using the Preact devtools, but I don't believe we have any tooling set up for checking signals/computed/effects themselves. However, you can still piece this together if you needed to using the internal properties. This would be a good place to start, with the mangle values providing a way to map those properties. const count = signal(0);
const count2 = computed(() => count.value + 1);
console.log(count.t) // can pull targets from this as you need. I won't pretend this is super user friendly -- it's not. Generally you shouldn't need this though. Tracking signal subscriptions are pretty easy, as you're just following the variable? |
Beta Was this translation helpful? Give feedback.
-
@rschristian thanks for pointer, but I wanted to ask how one can find all the computeds that use (subscribe to?) a signal? I can find all the effects of a signal by traversing |
Beta Was this translation helpful? Give feedback.
-
A common problem I'm facing is trying to debug why i given signal is being subscribed to?
Are there any general recommendations for such situations?
Something that would help me are debug utilities for example to list all signals that are observed in a given effect, or list all subscriptions of a given signals.
Beta Was this translation helpful? Give feedback.
All reactions