remove skipped properties from serialized state #2113
Replies: 2 comments 4 replies
-
What are you really trying to do? You shouldn't need to remove any properties from the serialized state. If that's the case, they probably shouldn't be in the state in the first place |
Beta Was this translation helpful? Give feedback.
-
Hey, I have stumbled upon the need for such a functionality myself. My use case is the following:
The need arises to deduplicate this, as the I have to define stores like this: const store = defineStore('example', () => {
const apolloDerivate = ref()
function setApolloDerivate(newValue) {
// Not so trivial state setting logic based on multiple refs
}
return {
apolloDerivate: computed(() => apolloDerivate.value),
setApolloDerivate
}
}) Or use a utility function like: function nonSerializableRef() {
const dataRef = ref()
return computed({
get() {
return dataRef.value
},
set(newValue) {
dataRef.value = newValue
}
} Both solutions are quite verbose and bring the overhead (and performance issues) of an extra computed property, when in fact what I would like to do is to just use something like The component rendering logic takes care of building up the store correctly during the hydration process using the instantly resolved Apollo query result (from the cache). The components are architected this way to enable multiple data provider components upward the tree. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What problem is this solving
Pinia has the ability to skip the hydration of certain properties with
skipHydrate()
. However, there is currently no way to remove skipped properties from the serialized state.Proposed solution
Pinia could provide a function
filterSkipped
that would go overpinia.state.value
and remove the skipped properties.Describe alternatives you've considered
No response
Beta Was this translation helpful? Give feedback.
All reactions