From: Eduardo San Martin Morote Date: Thu, 19 May 2022 12:31:57 +0000 (+0200) Subject: docs: skipHydrate api X-Git-Tag: @pinia/nuxt@0.2.0~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b0c92cc592fbea910cc5b78f50d87dfb0162b10;p=thirdparty%2Fvuejs%2Fpinia.git docs: skipHydrate api --- diff --git a/packages/pinia/src/store.ts b/packages/pinia/src/store.ts index 8985c537..9987608a 100644 --- a/packages/pinia/src/store.ts +++ b/packages/pinia/src/store.ts @@ -84,6 +84,13 @@ const skipHydrateSymbol = __DEV__ : /* istanbul ignore next */ Symbol() const skipHydrateMap = /*#__PURE__*/ new WeakMap() +/** + * 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(obj: T): T { return isVue2 ? // in @vue/composition-api, the refs are sealed so defineProperty doesn't work...