Skip to content

Commit

Permalink
docs: skipHydrate api
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed May 19, 2022
1 parent 5d44937 commit 5b0c92c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/pinia/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ const skipHydrateSymbol = __DEV__
: /* istanbul ignore next */ Symbol()
const skipHydrateMap = /*#__PURE__*/ new WeakMap<any, any>()

/**
* Tells Pinia to skip the hydration process of a given object. This is useful in setup stores (only) when you return a
* stateful object in the store but it isn't really state. e.g. returning a router instance in a setup store.
*
* @param obj - target object
* @returns obj
*/
export function skipHydrate<T = any>(obj: T): T {
return isVue2
? // in @vue/composition-api, the refs are sealed so defineProperty doesn't work...
Expand Down

0 comments on commit 5b0c92c

Please sign in to comment.