]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
docs: skipHydrate api
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 19 May 2022 12:31:57 +0000 (14:31 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Thu, 19 May 2022 12:31:57 +0000 (14:31 +0200)
packages/pinia/src/store.ts

index 8985c537b02b366690aae5f848a29a3ccf70323f..9987608a21c9d9ce67f5e67397ffadb78bb7e6d3 100644 (file)
@@ -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...