-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: custom serialization #7223
base: build/v2
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 9009520 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Looks great, but what about deserialization those objects? |
That's what the createSerialized$ does |
Does this mean we might be able to serialize functions from other libraries, like vanilla js? |
FEAT: `NoSerializeSymbol`: objects that have this defined will not be serialized FEAT: `SerializerSymbol`: objects that have this defined as a function will get it called with the object as a parameter during serialization. The function should return the data that should be serialized. Use this to remove cached data, consolidate things etc.
aca1de8
to
47942f4
Compare
@Varixo @thejackshelton gaah I had forgotten to push the actual commit 😅 |
Yes exactly. You need to add a symbol prop that serializes the value and then provide a deserializer that will get called lazily. |
47942f4
to
9009520
Compare
commit: |
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
9009520
to
103e3c1
Compare
This PR adds symbols to mark objects as (no/yes)serializable via symbols instead of via a Set, adds a symbol prop that will get called on serialization for custom serialization, and provides a new Signal type that lazily manages a non-serializable value.
Note that this is basically the same as
useComputed$
, except that it is invalidated during SSR so that when the value gets read on the client it will always run the compute function.Also note that
useComputed$
now passes the previous value to the compute function, to keep the implementation compact. This seems like it might be useful, should we document this?Everything works, looking for comments on implementation, naming etc.