WebReflection / usignal

A blend of @preact/signals-core and solid-js basic reactivity API
ISC License
221 stars 15 forks source link

feat: add toJSON #2

Closed qwelias closed 2 years ago

qwelias commented 2 years ago

Same reasoning as for valueOf, not sure how to update README tho

WebReflection commented 2 years ago

ok, because I've seen this only now, I might land the change with README update and everything but I'd like to brainstorm a bit here ... wouldn't be better if toJSON() returns {value: this.value} instead? That looks like a more explicit representation about the fact the value was a signal to me, but maybe others already do the normal toJSON dance and that's just the value indeed? 🤔

WebReflection commented 2 years ago

@qwelias uhm ... actually that's not symmetric on parse(stringify(signal)) so maybe mine is not a good idea ... thoughts?

WebReflection commented 2 years ago

I've went ahead and added toJSON s you suggested, it's published now.