Skip to content
Source
Sign inSign up
TanStack/router

fix: allow to express dependencies between serialization adapters #5314

Mergedschiller-manuel(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/5314/headmerged by schiller-manuel(GitHub profile, opens in a new tab)

Showing 9 changed files with 96 additions and 2 deletions (loading 5).

x
0 of 9 viewed, 9 left
32 additions and 0 deletionse2e/react-start/serialization-adapters/src/data.tsxModified
View file
@@ -88,7 +88,39 @@
},
+export class NestedOuter {
+ constructor(public inner: NestedInner) {}
+ whisper() {
+ return this.inner.value.toLowerCase()
+ }
+}
​
+export class NestedInner {
+ constructor(public value: string) {}
+ shout() {
+ return this.value.toUpperCase()
+ }
+}
+​
+export const nestedInnerAdapter = createSerializationAdapter({
+ key: 'nestedInner',
+ test: (value): value is NestedInner => value instanceof NestedInner,
+ toSerializable: (inner) => inner.value,
+ fromSerializable: (value) => new NestedInner(value),
+})
+​
+export const nestedOuterAdapter = createSerializationAdapter({