Replies: 1 comment
-
Your pseudo-code looks good, and it's DEV-only. However, I wonder if there are any pitfalls. If you are using the babel plugin anyway, I think it feels safer to add the function names with the plugin: const countAtom = atom(0)
const doubleAtom = atom((get) => get(countAtom) * 2)
doubleAtom.debugLabel = `doubleAtom`;
if (doubleAtom.read && !doubleAtom.read.name) doubleAtom.read.name = `doubleAtomRead`;
if (doubleAtom.write && !doubleAtom.write.name) doubleAtom.write.name = `doubleAtomWrite`; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We were recently debugging an issue with the store and async atoms (a bug which the experimental store seems to fix btw, so that's great 🌟 ), and while we were trying to hone down which atoms were causing the issue, having a stack trace of mostly anonymous functions was not particularly useful. We are debating whether to pass in named functions as
read
functions to derived atoms at the cost of readability. I thought maybe there could be a way to give these read and write functions names based on thedebugLabel
assigned to its owning atom.So instead of having to write:
We could write:
And since the babel plugin seems to give atoms their debugLabel automatically anyway, this would improve our debugging experience a ton.
In pseudo-code, we could do something like this in the
atom
function:Beta Was this translation helpful? Give feedback.
All reactions