Enhance API compatibility: toJSON, toString#28
Enhance API compatibility: toJSON, toString#28dy wants to merge 3 commits intoWebReflection:mainfrom
Conversation
Added toString and toJSON methods to Signal class.
|
I've always been a bit skeptical about |
|
Preact-signals have it added in preactjs/signals#320 due to 2 reports. |
|
An another compatibility issue here. It would need wrapping import {effect as _effect} from 'alien-signals'
export const effect = fn => {
let teardown, dispose = _effect(() => (typeof teardown === 'function' && teardown(), teardown = fn()));
return () => (typeof teardown === 'function' && teardown(), dispose());
} |
|
but in practice you send JSON to servers and automatically sending new requests feels a bit weird to me ... anyway, mind amending the MR with your latest finding too? thanks! |
|
Sure, added with test. |
|
@WebReflection please merge if makes sense |
Hi @WebReflection!
This adds
toStringandtoJSONmethods to make it more compatible with preact-signals API.Lmk if you'd prefer casting result to string instead of
{T}.