pmndrs / swc-jotai

MIT License
93 stars 16 forks source link

Could we add a feature into `@swc-jotai/debug-label` so that this provides a fallback but otherwise uses a `.debugLabel` if one already exists? #32

Open sebinsua opened 4 months ago

sebinsua commented 4 months ago

Could we add a feature into @swc-jotai/debug-label so that this provides a fallback label but otherwise uses a .debugLabel if one already exists?

e.g.

countAtom.debugLabel = countAtom.debugLabel ?? "countAtom";

The reason I'm interested in this, is that, often when I'm using atom families to create atoms, I give each atom a parameterised debug label relating to the params it was initialised with, etc.

I might attempt creating this if you're interested in the feature...

Note: I've just seen that one of your tests is that you don't add a label if one already exists, however, this doesn't work for me as I am using a helper function to apply debugLabel and debugPrivate.

Thisen commented 3 months ago

Good idea. Give it a shot and let's see if we like it.