-
-
Notifications
You must be signed in to change notification settings - Fork 23
Closed
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the feature has not already been requested
🚀 Feature Proposal
The defaultStoreValue could accept a factory function.
Motivation
This is a similar approach used in different store libs (ie. vuex, pinia).
Currently when passing default values by the store, when the value is an object, it is shared between requests what could be not what we want. The side effects of this can be hard to find when someone is not aware of this and instead of setting the whole data by key mutates the members of object what user got from context (like in #125).
Example
fastify.register(fastifyRequestContextPlugin, {
hook: 'preValidation',
defaultStoreValues: () => ({
user: { id: 'system' }
})
});Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels