From 5e893b36c3d4f4aa860b5e75f982cac8cb30f65c Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 25 Jul 2022 11:36:02 +0200 Subject: [PATCH] docs: update api --- packages/docs/api/enums/pinia.MutationType.md | 14 +- .../pinia.DefineSetupStoreOptions.md | 8 +- .../interfaces/pinia.DefineStoreOptions.md | 55 +++-- .../pinia.DefineStoreOptionsInPlugin.md | 55 +++-- packages/docs/api/interfaces/pinia.Pinia.md | 36 +-- .../interfaces/pinia.PiniaCustomProperties.md | 96 +------- .../docs/api/interfaces/pinia.PiniaPlugin.md | 6 +- .../interfaces/pinia.PiniaPluginContext.md | 10 +- .../api/interfaces/pinia.StoreDefinition.md | 4 +- .../api/interfaces/pinia.StoreProperties.md | 4 +- ...inia.SubscriptionCallbackMutationDirect.md | 6 +- ...bscriptionCallbackMutationPatchFunction.md | 6 +- ...SubscriptionCallbackMutationPatchObject.md | 8 +- .../pinia._StoreOnActionListenerContext.md | 79 +++--- .../api/interfaces/pinia._StoreWithState.md | 28 +-- ...pinia._SubscriptionCallbackMutationBase.md | 4 +- .../interfaces/pinia_nuxt.PiniaNuxtOptions.md | 26 -- .../pinia_testing.TestingOptions.md | 84 ++++--- .../interfaces/pinia_testing.TestingPinia.md | 48 ++-- packages/docs/api/modules/pinia.md | 231 +++++++++++------- packages/docs/api/modules/pinia_nuxt.md | 11 +- packages/docs/api/modules/pinia_testing.md | 2 +- 22 files changed, 401 insertions(+), 420 deletions(-) delete mode 100644 packages/docs/api/interfaces/pinia_nuxt.PiniaNuxtOptions.md diff --git a/packages/docs/api/enums/pinia.MutationType.md b/packages/docs/api/enums/pinia.MutationType.md index a315f0d5..86dd80d6 100644 --- a/packages/docs/api/enums/pinia.MutationType.md +++ b/packages/docs/api/enums/pinia.MutationType.md @@ -12,11 +12,11 @@ sidebarDepth: 3 Possible types for SubscriptionCallback -## Enumeration members +## Enumeration Members ### direct -• **direct** = `"direct"` +• **direct** = ``"direct"`` Direct mutation of the state: @@ -26,13 +26,13 @@ Direct mutation of the state: #### Defined in -[packages/pinia/src/types.ts:50](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L50) +[packages/pinia/src/types.ts:50](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L50) ___ ### patchFunction -• **patchFunction** = `"patch function"` +• **patchFunction** = ``"patch function"`` Mutated the state with `$patch` and a function @@ -40,13 +40,13 @@ Mutated the state with `$patch` and a function #### Defined in -[packages/pinia/src/types.ts:64](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L64) +[packages/pinia/src/types.ts:64](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L64) ___ ### patchObject -• **patchObject** = `"patch object"` +• **patchObject** = ``"patch object"`` Mutated the state with `$patch` and an object @@ -54,4 +54,4 @@ Mutated the state with `$patch` and an object #### Defined in -[packages/pinia/src/types.ts:57](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L57) +[packages/pinia/src/types.ts:57](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L57) diff --git a/packages/docs/api/interfaces/pinia.DefineSetupStoreOptions.md b/packages/docs/api/interfaces/pinia.DefineSetupStoreOptions.md index 4c9bf637..3c93b4e3 100644 --- a/packages/docs/api/interfaces/pinia.DefineSetupStoreOptions.md +++ b/packages/docs/api/interfaces/pinia.DefineSetupStoreOptions.md @@ -11,7 +11,11 @@ sidebarDepth: 3 [pinia](../modules/pinia.md).DefineSetupStoreOptions Options parameter of `defineStore()` for setup stores. Can be extended to -augment stores with the plugin API. @see [DefineStoreOptionsBase](pinia.DefineStoreOptionsBase.md). +augment stores with the plugin API. + +**`See`** + +[DefineStoreOptionsBase](pinia.DefineStoreOptionsBase.md). ## Type parameters @@ -40,4 +44,4 @@ store defined with a setup function. Note this is always defined #### Defined in -[packages/pinia/src/types.ts:704](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L704) +[packages/pinia/src/types.ts:697](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L697) diff --git a/packages/docs/api/interfaces/pinia.DefineStoreOptions.md b/packages/docs/api/interfaces/pinia.DefineStoreOptions.md index 94946e48..64117274 100644 --- a/packages/docs/api/interfaces/pinia.DefineStoreOptions.md +++ b/packages/docs/api/interfaces/pinia.DefineStoreOptions.md @@ -11,7 +11,11 @@ sidebarDepth: 3 [pinia](../modules/pinia.md).DefineStoreOptions Options parameter of `defineStore()` for option stores. Can be extended to -augment stores with the plugin API. @see [DefineStoreOptionsBase](pinia.DefineStoreOptionsBase.md). +augment stores with the plugin API. + +**`See`** + +[DefineStoreOptionsBase](pinia.DefineStoreOptionsBase.md). ## Type parameters @@ -38,7 +42,7 @@ Optional object of actions. #### Defined in -[packages/pinia/src/types.ts:652](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L652) +[packages/pinia/src/types.ts:645](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L645) ___ @@ -50,7 +54,7 @@ Optional object of getters. #### Defined in -[packages/pinia/src/types.ts:645](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L645) +[packages/pinia/src/types.ts:638](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L638) ___ @@ -62,7 +66,28 @@ Unique string key to identify the store across the application. #### Defined in -[packages/pinia/src/types.ts:634](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L634) +[packages/pinia/src/types.ts:627](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L627) + +___ + +### state + +• `Optional` **state**: () => `S` + +#### Type declaration + +▸ (): `S` + +Function to create a fresh state. **Must be an arrow function** to ensure +correct typings! + +##### Returns + +`S` + +#### Defined in + +[packages/pinia/src/types.ts:633](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L633) ## Methods @@ -73,7 +98,8 @@ Unique string key to identify the store across the application. Allows hydrating the store during SSR when complex state (like client side only refs) are used in the store definition and copying the value from `pinia.state` isn't enough. -**`example`** +**`Example`** + If in your `state`, you use any `customRef`s, any `computed`s, or any `ref`s that have a different value on Server and Client, you need to manually hydrate them. e.g., a custom ref that is stored in the local storage: @@ -103,21 +129,4 @@ const useStore = defineStore('main', { #### Defined in -[packages/pinia/src/types.ts:685](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L685) - -___ - -### state - -▸ `Optional` **state**(): `S` - -Function to create a fresh state. **Must be an arrow function** to ensure -correct typings! - -#### Returns - -`S` - -#### Defined in - -[packages/pinia/src/types.ts:640](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L640) +[packages/pinia/src/types.ts:678](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L678) diff --git a/packages/docs/api/interfaces/pinia.DefineStoreOptionsInPlugin.md b/packages/docs/api/interfaces/pinia.DefineStoreOptionsInPlugin.md index 52baf801..c0ac78e8 100644 --- a/packages/docs/api/interfaces/pinia.DefineStoreOptionsInPlugin.md +++ b/packages/docs/api/interfaces/pinia.DefineStoreOptionsInPlugin.md @@ -39,7 +39,7 @@ Defaults to an empty object if no actions are defined. #### Defined in -[packages/pinia/src/types.ts:721](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L721) +[packages/pinia/src/types.ts:714](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L714) ___ @@ -55,7 +55,32 @@ Omit.getters #### Defined in -[packages/pinia/src/types.ts:645](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L645) +[packages/pinia/src/types.ts:638](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L638) + +___ + +### state + +• `Optional` **state**: () => `S` + +#### Type declaration + +▸ (): `S` + +Function to create a fresh state. **Must be an arrow function** to ensure +correct typings! + +##### Returns + +`S` + +#### Inherited from + +Omit.state + +#### Defined in + +[packages/pinia/src/types.ts:633](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L633) ## Methods @@ -66,7 +91,8 @@ Omit.getters Allows hydrating the store during SSR when complex state (like client side only refs) are used in the store definition and copying the value from `pinia.state` isn't enough. -**`example`** +**`Example`** + If in your `state`, you use any `customRef`s, any `computed`s, or any `ref`s that have a different value on Server and Client, you need to manually hydrate them. e.g., a custom ref that is stored in the local storage: @@ -100,25 +126,4 @@ Omit.hydrate #### Defined in -[packages/pinia/src/types.ts:685](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L685) - -___ - -### state - -▸ `Optional` **state**(): `S` - -Function to create a fresh state. **Must be an arrow function** to ensure -correct typings! - -#### Returns - -`S` - -#### Inherited from - -Omit.state - -#### Defined in - -[packages/pinia/src/types.ts:640](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L640) +[packages/pinia/src/types.ts:678](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L678) diff --git a/packages/docs/api/interfaces/pinia.Pinia.md b/packages/docs/api/interfaces/pinia.Pinia.md index 776bdee1..0119cd5f 100644 --- a/packages/docs/api/interfaces/pinia.Pinia.md +++ b/packages/docs/api/interfaces/pinia.Pinia.md @@ -20,38 +20,42 @@ Every application must own its own pinia to be able to create stores ## Properties -### state - -• **state**: `Ref`<`Record`<`string`, [`StateTree`](../modules/pinia.md#statetree)\>\> - -root state - -#### Defined in - -[packages/pinia/src/rootStore.ts:51](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/rootStore.ts#L51) +### install -## Methods +• **install**: (`app`: `App`<`any`\>) => `void` -### install +#### Type declaration -▸ **install**(`app`): `void` +▸ (`app`): `void` -#### Parameters +##### Parameters | Name | Type | | :------ | :------ | | `app` | `App`<`any`\> | -#### Returns +##### Returns `void` #### Defined in -[packages/pinia/src/rootStore.ts:46](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/rootStore.ts#L46) +[packages/pinia/src/rootStore.ts:46](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/rootStore.ts#L46) ___ +### state + +• **state**: `Ref`<`Record`<`string`, [`StateTree`](../modules/pinia.md#statetree)\>\> + +root state + +#### Defined in + +[packages/pinia/src/rootStore.ts:51](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/rootStore.ts#L51) + +## Methods + ### use ▸ **use**(`plugin`): [`Pinia`](pinia.Pinia.md) @@ -70,4 +74,4 @@ Adds a store plugin to extend every store #### Defined in -[packages/pinia/src/rootStore.ts:58](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/rootStore.ts#L58) +[packages/pinia/src/rootStore.ts:58](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/rootStore.ts#L58) diff --git a/packages/docs/api/interfaces/pinia.PiniaCustomProperties.md b/packages/docs/api/interfaces/pinia.PiniaCustomProperties.md index 41485f85..5cc98377 100644 --- a/packages/docs/api/interfaces/pinia.PiniaCustomProperties.md +++ b/packages/docs/api/interfaces/pinia.PiniaCustomProperties.md @@ -21,98 +21,6 @@ Interface to be extended by the user when they add properties through plugins. | `G` | [`_GettersTree`](../modules/pinia.md#_getterstree)<`S`\> | | `A` | [`_ActionsTree`](../modules/pinia.md#_actionstree) | -## Properties - -### $nuxt - -• **$nuxt**: `Context` - -Nuxt context. - -#### Defined in - -[packages/nuxt/src/module.ts:68](https://github.com/vuejs/pinia/blob/2b998ee/packages/nuxt/src/module.ts#L68) - -___ - -### double - -• **double**: `number` - -#### Defined in - -[packages/pinia/__tests__/storePlugins.spec.ts:14](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/__tests__/storePlugins.spec.ts#L14) - -___ - -### globalA - -• **globalA**: `string` - -#### Defined in - -[packages/pinia/__tests__/storePlugins.spec.ts:11](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/__tests__/storePlugins.spec.ts#L11) - -___ - -### globalB - -• **globalB**: `string` - -#### Defined in - -[packages/pinia/__tests__/storePlugins.spec.ts:12](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/__tests__/storePlugins.spec.ts#L12) - -___ - -### hasApp - -• **hasApp**: `boolean` - -#### Defined in - -[packages/pinia/__tests__/storePlugins.spec.ts:9](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/__tests__/storePlugins.spec.ts#L9) - -___ - -### idFromPlugin - -• **idFromPlugin**: `Id` - -#### Defined in - -[packages/pinia/__tests__/storePlugins.spec.ts:10](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/__tests__/storePlugins.spec.ts#L10) - -___ - -### pluginN - -• **pluginN**: `number` - -#### Defined in - -[packages/pinia/__tests__/storePlugins.spec.ts:7](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/__tests__/storePlugins.spec.ts#L7) - -___ - -### shared - -• **shared**: `number` - -#### Defined in - -[packages/pinia/__tests__/storePlugins.spec.ts:13](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/__tests__/storePlugins.spec.ts#L13) - -___ - -### uid - -• **uid**: `number` - -#### Defined in - -[packages/pinia/__tests__/storePlugins.spec.ts:8](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/__tests__/storePlugins.spec.ts#L8) - ## Accessors ### route @@ -125,7 +33,7 @@ ___ #### Defined in -[packages/playground/src/main.ts:17](https://github.com/vuejs/pinia/blob/2b998ee/packages/playground/src/main.ts#L17) +[packages/playground/src/main.ts:17](https://github.com/vuejs/pinia/blob/aa0192a/packages/playground/src/main.ts#L17) • `set` **route**(`value`): `void` @@ -141,4 +49,4 @@ ___ #### Defined in -[packages/playground/src/main.ts:14](https://github.com/vuejs/pinia/blob/2b998ee/packages/playground/src/main.ts#L14) +[packages/playground/src/main.ts:14](https://github.com/vuejs/pinia/blob/aa0192a/packages/playground/src/main.ts#L14) diff --git a/packages/docs/api/interfaces/pinia.PiniaPlugin.md b/packages/docs/api/interfaces/pinia.PiniaPlugin.md index b4be4a93..136546b5 100644 --- a/packages/docs/api/interfaces/pinia.PiniaPlugin.md +++ b/packages/docs/api/interfaces/pinia.PiniaPlugin.md @@ -14,7 +14,7 @@ sidebarDepth: 3 ### PiniaPlugin -▸ **PiniaPlugin**(`context`): `void` \| `Partial`<[`PiniaCustomProperties`](pinia.PiniaCustomProperties.md)<`string`, [`StateTree`](../modules/pinia.md#statetree), [`_GettersTree`](../modules/pinia.md#_getterstree)<[`StateTree`](../modules/pinia.md#statetree)\>, [`_ActionsTree`](../modules/pinia.md#_actionstree)\> & `PiniaCustomStateProperties`<[`StateTree`](../modules/pinia.md#statetree)\>\> +▸ **PiniaPlugin**(`context`): `void` \| `Partial`<[`PiniaCustomProperties`](pinia.PiniaCustomProperties.md)<`string`, [`StateTree`](../modules/pinia.md#statetree), [`_GettersTree`](../modules/pinia.md#_getterstree)<[`StateTree`](../modules/pinia.md#statetree)\>, [`_ActionsTree`](../modules/pinia.md#_actionstree)\> & [`PiniaCustomStateProperties`](pinia.PiniaCustomStateProperties.md)<[`StateTree`](../modules/pinia.md#statetree)\>\> Plugin to extend every store. Returns an object to extend the store or nothing. @@ -27,8 +27,8 @@ nothing. #### Returns -`void` \| `Partial`<[`PiniaCustomProperties`](pinia.PiniaCustomProperties.md)<`string`, [`StateTree`](../modules/pinia.md#statetree), [`_GettersTree`](../modules/pinia.md#_getterstree)<[`StateTree`](../modules/pinia.md#statetree)\>, [`_ActionsTree`](../modules/pinia.md#_actionstree)\> & `PiniaCustomStateProperties`<[`StateTree`](../modules/pinia.md#statetree)\>\> +`void` \| `Partial`<[`PiniaCustomProperties`](pinia.PiniaCustomProperties.md)<`string`, [`StateTree`](../modules/pinia.md#statetree), [`_GettersTree`](../modules/pinia.md#_getterstree)<[`StateTree`](../modules/pinia.md#statetree)\>, [`_ActionsTree`](../modules/pinia.md#_actionstree)\> & [`PiniaCustomStateProperties`](pinia.PiniaCustomStateProperties.md)<[`StateTree`](../modules/pinia.md#statetree)\>\> #### Defined in -[packages/pinia/src/rootStore.ts:140](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/rootStore.ts#L140) +[packages/pinia/src/rootStore.ts:140](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/rootStore.ts#L140) diff --git a/packages/docs/api/interfaces/pinia.PiniaPluginContext.md b/packages/docs/api/interfaces/pinia.PiniaPluginContext.md index 671a8553..de736ab8 100644 --- a/packages/docs/api/interfaces/pinia.PiniaPluginContext.md +++ b/packages/docs/api/interfaces/pinia.PiniaPluginContext.md @@ -31,7 +31,7 @@ Current app created with `Vue.createApp()`. #### Defined in -[packages/pinia/src/rootStore.ts:117](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/rootStore.ts#L117) +[packages/pinia/src/rootStore.ts:117](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/rootStore.ts#L117) ___ @@ -39,11 +39,11 @@ ___ • **options**: [`DefineStoreOptionsInPlugin`](pinia.DefineStoreOptionsInPlugin.md)<`Id`, `S`, `G`, `A`\> -Options object defining the store passed to `defineStore()`. +Initial options defining the store when calling `defineStore()`. #### Defined in -[packages/pinia/src/rootStore.ts:127](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/rootStore.ts#L127) +[packages/pinia/src/rootStore.ts:127](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/rootStore.ts#L127) ___ @@ -55,7 +55,7 @@ pinia instance. #### Defined in -[packages/pinia/src/rootStore.ts:112](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/rootStore.ts#L112) +[packages/pinia/src/rootStore.ts:112](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/rootStore.ts#L112) ___ @@ -67,4 +67,4 @@ Current store being extended. #### Defined in -[packages/pinia/src/rootStore.ts:122](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/rootStore.ts#L122) +[packages/pinia/src/rootStore.ts:122](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/rootStore.ts#L122) diff --git a/packages/docs/api/interfaces/pinia.StoreDefinition.md b/packages/docs/api/interfaces/pinia.StoreDefinition.md index e2657f6b..a8f865d2 100644 --- a/packages/docs/api/interfaces/pinia.StoreDefinition.md +++ b/packages/docs/api/interfaces/pinia.StoreDefinition.md @@ -40,7 +40,7 @@ Returns a store, creates it if necessary. #### Defined in -[packages/pinia/src/types.ts:511](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L511) +[packages/pinia/src/types.ts:504](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L504) ## Properties @@ -52,4 +52,4 @@ Id of the store. Used by map helpers. #### Defined in -[packages/pinia/src/types.ts:516](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L516) +[packages/pinia/src/types.ts:509](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L509) diff --git a/packages/docs/api/interfaces/pinia.StoreProperties.md b/packages/docs/api/interfaces/pinia.StoreProperties.md index 9f573e3c..73bd1dbe 100644 --- a/packages/docs/api/interfaces/pinia.StoreProperties.md +++ b/packages/docs/api/interfaces/pinia.StoreProperties.md @@ -34,7 +34,7 @@ Unique identifier of the store #### Defined in -[packages/pinia/src/types.ts:265](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L265) +[packages/pinia/src/types.ts:258](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L258) ___ @@ -48,4 +48,4 @@ that should be displayed in devtools. #### Defined in -[packages/pinia/src/types.ts:293](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L293) +[packages/pinia/src/types.ts:286](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L286) diff --git a/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationDirect.md b/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationDirect.md index 17fcbcd4..a1c3fdbc 100644 --- a/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationDirect.md +++ b/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationDirect.md @@ -30,7 +30,7 @@ DEV ONLY. Different mutation calls. #### Defined in -[packages/pinia/src/types.ts:96](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L96) +[packages/pinia/src/types.ts:96](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L96) ___ @@ -46,7 +46,7 @@ ___ #### Defined in -[packages/pinia/src/types.ts:81](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L81) +[packages/pinia/src/types.ts:81](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L81) ___ @@ -62,4 +62,4 @@ Type of the mutation. #### Defined in -[packages/pinia/src/types.ts:91](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L91) +[packages/pinia/src/types.ts:91](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L91) diff --git a/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchFunction.md b/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchFunction.md index bc79cc5a..a75be62a 100644 --- a/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchFunction.md +++ b/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchFunction.md @@ -29,7 +29,7 @@ DEV ONLY. Array of all the mutations done inside of the callback. #### Defined in -[packages/pinia/src/types.ts:129](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L129) +[packages/pinia/src/types.ts:129](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L129) ___ @@ -45,7 +45,7 @@ ___ #### Defined in -[packages/pinia/src/types.ts:81](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L81) +[packages/pinia/src/types.ts:81](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L81) ___ @@ -61,4 +61,4 @@ Type of the mutation. #### Defined in -[packages/pinia/src/types.ts:124](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L124) +[packages/pinia/src/types.ts:124](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L124) diff --git a/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchObject.md b/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchObject.md index 4fc2fa9f..5e894d1e 100644 --- a/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchObject.md +++ b/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchObject.md @@ -35,7 +35,7 @@ DEV ONLY. Array for patch calls. #### Defined in -[packages/pinia/src/types.ts:110](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L110) +[packages/pinia/src/types.ts:110](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L110) ___ @@ -47,7 +47,7 @@ Object passed to `store.$patch()`. #### Defined in -[packages/pinia/src/types.ts:115](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L115) +[packages/pinia/src/types.ts:115](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L115) ___ @@ -63,7 +63,7 @@ ___ #### Defined in -[packages/pinia/src/types.ts:81](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L81) +[packages/pinia/src/types.ts:81](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L81) ___ @@ -79,4 +79,4 @@ Type of the mutation. #### Defined in -[packages/pinia/src/types.ts:105](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L105) +[packages/pinia/src/types.ts:105](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L105) diff --git a/packages/docs/api/interfaces/pinia._StoreOnActionListenerContext.md b/packages/docs/api/interfaces/pinia._StoreOnActionListenerContext.md index 236bb754..582e76e2 100644 --- a/packages/docs/api/interfaces/pinia._StoreOnActionListenerContext.md +++ b/packages/docs/api/interfaces/pinia._StoreOnActionListenerContext.md @@ -24,83 +24,90 @@ For internal use **only** ## Properties -### args +### after -• **args**: `A` extends `Record`<`ActionName`, [`_Method`](../modules/pinia.md#_method)\> ? `Parameters`<`A`[`ActionName`]\> : `unknown`[] +• **after**: (`callback`: `A` extends `Record`<`ActionName`, [`_Method`](../modules/pinia.md#_method)\> ? (`resolvedReturn`: [`_Awaited`](../modules/pinia.md#_awaited)<`ReturnType`<`A`[`ActionName`]\>\>) => `void` : () => `void`) => `void` -Parameters passed to the action +#### Type declaration -#### Defined in +▸ (`callback`): `void` -[packages/pinia/src/types.ts:195](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L195) +Sets up a hook once the action is finished. It receives the return value +of the action, if it's a Promise, it will be unwrapped. -___ +##### Parameters -### name +| Name | Type | +| :------ | :------ | +| `callback` | `A` extends `Record`<`ActionName`, [`_Method`](../modules/pinia.md#_method)\> ? (`resolvedReturn`: [`_Awaited`](../modules/pinia.md#_awaited)<`ReturnType`<`A`[`ActionName`]\>\>) => `void` : () => `void` | -• **name**: `ActionName` +##### Returns -Name of the action +`void` #### Defined in -[packages/pinia/src/types.ts:185](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L185) +[packages/pinia/src/types.ts:203](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L203) ___ -### store +### args -• **store**: `Store` +• **args**: `A` extends `Record`<`ActionName`, [`_Method`](../modules/pinia.md#_method)\> ? `Parameters`<`A`[`ActionName`]\> : `unknown`[] -Store that is invoking the action +Parameters passed to the action #### Defined in -[packages/pinia/src/types.ts:190](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L190) - -## Methods - -### after - -▸ **after**(`callback`): `void` +[packages/pinia/src/types.ts:195](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L195) -Sets up a hook once the action is finished. It receives the return value -of the action, if it's a Promise, it will be unwrapped. Can return a -value (other than `undefined`) to **override** the returned value. - -#### Parameters +___ -| Name | Type | -| :------ | :------ | -| `callback` | `A` extends `Record`<`ActionName`, [`_Method`](../modules/pinia.md#_method)\> ? (`resolvedReturn`: [`_Awaited`](../modules/pinia.md#_awaited)<`ReturnType`<`A`[`ActionName`]\>\>) => `void` \| `ReturnType`<`A`[`ActionName`]\> \| [`_Awaited`](../modules/pinia.md#_awaited)<`ReturnType`<`A`[`ActionName`]\>\> : () => `void` | +### name -#### Returns +• **name**: `ActionName` -`void` +Name of the action #### Defined in -[packages/pinia/src/types.ts:204](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L204) +[packages/pinia/src/types.ts:185](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L185) ___ ### onError -▸ **onError**(`callback`): `void` +• **onError**: (`callback`: (`error`: `unknown`) => `void`) => `void` + +#### Type declaration + +▸ (`callback`): `void` Sets up a hook if the action fails. Return `false` to catch the error and stop it fro propagating. -#### Parameters +##### Parameters | Name | Type | | :------ | :------ | -| `callback` | (`error`: `unknown`) => `unknown` | +| `callback` | (`error`: `unknown`) => `void` | -#### Returns +##### Returns `void` #### Defined in -[packages/pinia/src/types.ts:220](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L220) +[packages/pinia/src/types.ts:213](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L213) + +___ + +### store + +• **store**: `Store` + +Store that is invoking the action + +#### Defined in + +[packages/pinia/src/types.ts:190](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L190) diff --git a/packages/docs/api/interfaces/pinia._StoreWithState.md b/packages/docs/api/interfaces/pinia._StoreWithState.md index 6febbb8b..6218335c 100644 --- a/packages/docs/api/interfaces/pinia._StoreWithState.md +++ b/packages/docs/api/interfaces/pinia._StoreWithState.md @@ -41,19 +41,19 @@ Unique identifier of the store #### Defined in -[packages/pinia/src/types.ts:265](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L265) +[packages/pinia/src/types.ts:258](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L258) ___ ### $state -• **$state**: `UnwrapRef`<`S`\> & `PiniaCustomStateProperties`<`S`\> +• **$state**: `UnwrapRef`<`S`\> & [`PiniaCustomStateProperties`](pinia.PiniaCustomStateProperties.md)<`S`\> State of the Store. Setting it will replace the whole state. #### Defined in -[packages/pinia/src/types.ts:335](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L335) +[packages/pinia/src/types.ts:328](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L328) ___ @@ -71,7 +71,7 @@ that should be displayed in devtools. #### Defined in -[packages/pinia/src/types.ts:293](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L293) +[packages/pinia/src/types.ts:286](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L286) ## Methods @@ -89,7 +89,7 @@ e.g. devtools plugin stops displaying disposed stores from devtools. #### Defined in -[packages/pinia/src/types.ts:423](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L423) +[packages/pinia/src/types.ts:416](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L416) ___ @@ -111,7 +111,7 @@ It also returns a function to remove the callback. Note than when calling `store.$onAction()` inside of a component, it will be automatically cleaned up when the component gets unmounted unless `detached` is set to true. -**`example`** +**`Example`** ```js store.$onAction(({ after, onError }) => { @@ -157,7 +157,7 @@ It also returns a function to remove the callback. Note than when calling `store.$onAction()` inside of a component, it will be automatically cleaned up when the component gets unmounted unless `detached` is set to true. -**`example`** +**`Example`** ```js store.$onAction(({ after, onError }) => { @@ -182,7 +182,7 @@ function that removes the watcher #### Defined in -[packages/pinia/src/types.ts:413](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L413) +[packages/pinia/src/types.ts:406](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L406) ___ @@ -204,7 +204,7 @@ Applies a state patch to current state. Allows passing nested values #### Defined in -[packages/pinia/src/types.ts:342](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L342) +[packages/pinia/src/types.ts:335](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L335) ▸ **$patch**<`F`\>(`stateMutator`): `void` @@ -230,7 +230,7 @@ to an array. The function passed to `$patch()` **must be synchronous**. #### Defined in -[packages/pinia/src/types.ts:351](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L351) +[packages/pinia/src/types.ts:344](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L344) ___ @@ -247,7 +247,7 @@ TODO: make this options only #### Defined in -[packages/pinia/src/types.ts:360](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L360) +[packages/pinia/src/types.ts:353](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L353) ___ @@ -256,7 +256,7 @@ ___ ▸ **$subscribe**(`callback`, `options?`): () => `void` Setups a callback to be called whenever the state changes. It also returns a function to remove the callback. Note -than when calling `store.$subscribe()` inside of a component, it will be automatically cleaned up when the +that when calling `store.$subscribe()` inside of a component, it will be automatically cleaned up when the component gets unmounted unless `detached` is set to true. #### Parameters @@ -275,7 +275,7 @@ function that removes the watcher ▸ (): `void` Setups a callback to be called whenever the state changes. It also returns a function to remove the callback. Note -than when calling `store.$subscribe()` inside of a component, it will be automatically cleaned up when the +that when calling `store.$subscribe()` inside of a component, it will be automatically cleaned up when the component gets unmounted unless `detached` is set to true. ##### Returns @@ -286,4 +286,4 @@ function that removes the watcher #### Defined in -[packages/pinia/src/types.ts:372](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L372) +[packages/pinia/src/types.ts:365](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L365) diff --git a/packages/docs/api/interfaces/pinia._SubscriptionCallbackMutationBase.md b/packages/docs/api/interfaces/pinia._SubscriptionCallbackMutationBase.md index 119b8fe9..f76c5325 100644 --- a/packages/docs/api/interfaces/pinia._SubscriptionCallbackMutationBase.md +++ b/packages/docs/api/interfaces/pinia._SubscriptionCallbackMutationBase.md @@ -32,7 +32,7 @@ Base type for the context passed to a subscription callback. Internal type. #### Defined in -[packages/pinia/src/types.ts:81](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L81) +[packages/pinia/src/types.ts:81](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L81) ___ @@ -44,4 +44,4 @@ Type of the mutation. #### Defined in -[packages/pinia/src/types.ts:76](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L76) +[packages/pinia/src/types.ts:76](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L76) diff --git a/packages/docs/api/interfaces/pinia_nuxt.PiniaNuxtOptions.md b/packages/docs/api/interfaces/pinia_nuxt.PiniaNuxtOptions.md deleted file mode 100644 index bcaf7c50..00000000 --- a/packages/docs/api/interfaces/pinia_nuxt.PiniaNuxtOptions.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -sidebar: "auto" -editLinks: false -sidebarDepth: 3 ---- - -[API Documentation](../index.md) / [@pinia/nuxt](../modules/pinia_nuxt.md) / PiniaNuxtOptions - -# Interface: PiniaNuxtOptions - -[@pinia/nuxt](../modules/pinia_nuxt.md).PiniaNuxtOptions - -## Properties - -### disableVuex - -• `Optional` **disableVuex**: `boolean` - -Pinia disables Vuex by default, set this option to `false` to avoid it and -use Pinia alongside Vuex. - -**`default`** `true` - -#### Defined in - -[packages/nuxt/src/module.ts:15](https://github.com/vuejs/pinia/blob/2b998ee/packages/nuxt/src/module.ts#L15) diff --git a/packages/docs/api/interfaces/pinia_testing.TestingOptions.md b/packages/docs/api/interfaces/pinia_testing.TestingOptions.md index 87040b5f..eeb49b0e 100644 --- a/packages/docs/api/interfaces/pinia_testing.TestingOptions.md +++ b/packages/docs/api/interfaces/pinia_testing.TestingOptions.md @@ -12,6 +12,45 @@ sidebarDepth: 3 ## Properties +### createSpy + +• `Optional` **createSpy**: (`fn?`: (...`args`: `any`[]) => `any`) => (...`args`: `any`[]) => `any` + +#### Type declaration + +▸ (`fn?`): (...`args`: `any`[]) => `any` + +Function used to create a spy for actions and `$patch()`. Pre-configured +with `jest.fn()` in jest projects or `vi.fn()` in vitest projects. + +##### Parameters + +| Name | Type | +| :------ | :------ | +| `fn?` | (...`args`: `any`[]) => `any` | + +##### Returns + +`fn` + +▸ (...`args`): `any` + +##### Parameters + +| Name | Type | +| :------ | :------ | +| `...args` | `any`[] | + +##### Returns + +`any` + +#### Defined in + +[packages/testing/src/testing.ts:63](https://github.com/vuejs/pinia/blob/aa0192a/packages/testing/src/testing.ts#L63) + +___ + ### fakeApp • `Optional` **fakeApp**: `boolean` @@ -23,7 +62,7 @@ Defaults to false. #### Defined in -[packages/testing/src/testing.ts:57](https://github.com/vuejs/pinia/blob/2b998ee/packages/testing/src/testing.ts#L57) +[packages/testing/src/testing.ts:57](https://github.com/vuejs/pinia/blob/aa0192a/packages/testing/src/testing.ts#L57) ___ @@ -36,7 +75,7 @@ allowing you to only set a few properties that are required in your test. #### Defined in -[packages/testing/src/testing.ts:27](https://github.com/vuejs/pinia/blob/2b998ee/packages/testing/src/testing.ts#L27) +[packages/testing/src/testing.ts:27](https://github.com/vuejs/pinia/blob/aa0192a/packages/testing/src/testing.ts#L27) ___ @@ -49,7 +88,7 @@ your application that will be used while testing. #### Defined in -[packages/testing/src/testing.ts:33](https://github.com/vuejs/pinia/blob/2b998ee/packages/testing/src/testing.ts#L33) +[packages/testing/src/testing.ts:33](https://github.com/vuejs/pinia/blob/aa0192a/packages/testing/src/testing.ts#L33) ___ @@ -65,7 +104,7 @@ handle this in `createSpy()`. #### Defined in -[packages/testing/src/testing.ts:42](https://github.com/vuejs/pinia/blob/2b998ee/packages/testing/src/testing.ts#L42) +[packages/testing/src/testing.ts:42](https://github.com/vuejs/pinia/blob/aa0192a/packages/testing/src/testing.ts#L42) ___ @@ -79,39 +118,4 @@ argument `undefined`. You still have to handle this in `createSpy()`. #### Defined in -[packages/testing/src/testing.ts:49](https://github.com/vuejs/pinia/blob/2b998ee/packages/testing/src/testing.ts#L49) - -## Methods - -### createSpy - -▸ `Optional` **createSpy**(`fn?`): (...`args`: `any`[]) => `any` - -Function used to create a spy for actions and `$patch()`. Pre-configured -with `jest.fn()` in jest projects or `vi.fn()` in vitest projects. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `fn?` | (...`args`: `any`[]) => `any` | - -#### Returns - -`fn` - -▸ (...`args`): `any` - -##### Parameters - -| Name | Type | -| :------ | :------ | -| `...args` | `any`[] | - -##### Returns - -`any` - -#### Defined in - -[packages/testing/src/testing.ts:63](https://github.com/vuejs/pinia/blob/2b998ee/packages/testing/src/testing.ts#L63) +[packages/testing/src/testing.ts:49](https://github.com/vuejs/pinia/blob/aa0192a/packages/testing/src/testing.ts#L49) diff --git a/packages/docs/api/interfaces/pinia_testing.TestingPinia.md b/packages/docs/api/interfaces/pinia_testing.TestingPinia.md index 4ae65bdb..d4bed52f 100644 --- a/packages/docs/api/interfaces/pinia_testing.TestingPinia.md +++ b/packages/docs/api/interfaces/pinia_testing.TestingPinia.md @@ -11,7 +11,7 @@ sidebarDepth: 3 [@pinia/testing](../modules/pinia_testing.md).TestingPinia Pinia instance specifically designed for testing. Extends a regular -[Pinia](pinia.Pinia.md) instance with test specific properties. +Pinia instance with test specific properties. ## Hierarchy @@ -29,37 +29,25 @@ App used by Pinia #### Defined in -[packages/testing/src/testing.ts:72](https://github.com/vuejs/pinia/blob/2b998ee/packages/testing/src/testing.ts#L72) +[packages/testing/src/testing.ts:72](https://github.com/vuejs/pinia/blob/aa0192a/packages/testing/src/testing.ts#L72) ___ -### state - -• **state**: `Ref`<`Record`<`string`, [`StateTree`](../modules/pinia.md#statetree)\>\> - -root state - -#### Inherited from - -[Pinia](pinia.Pinia.md).[state](pinia.Pinia.md#state) - -#### Defined in - -[packages/pinia/src/rootStore.ts:51](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/rootStore.ts#L51) +### install -## Methods +• **install**: (`app`: `App`<`any`\>) => `void` -### install +#### Type declaration -▸ **install**(`app`): `void` +▸ (`app`): `void` -#### Parameters +##### Parameters | Name | Type | | :------ | :------ | | `app` | `App`<`any`\> | -#### Returns +##### Returns `void` @@ -69,10 +57,26 @@ root state #### Defined in -[packages/pinia/src/rootStore.ts:46](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/rootStore.ts#L46) +[packages/pinia/src/rootStore.ts:46](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/rootStore.ts#L46) ___ +### state + +• **state**: `Ref`<`Record`<`string`, [`StateTree`](../modules/pinia.md#statetree)\>\> + +root state + +#### Inherited from + +[Pinia](pinia.Pinia.md).[state](pinia.Pinia.md#state) + +#### Defined in + +[packages/pinia/src/rootStore.ts:51](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/rootStore.ts#L51) + +## Methods + ### use ▸ **use**(`plugin`): [`Pinia`](pinia.Pinia.md) @@ -95,4 +99,4 @@ Adds a store plugin to extend every store #### Defined in -[packages/pinia/src/rootStore.ts:58](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/rootStore.ts#L58) +[packages/pinia/src/rootStore.ts:58](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/rootStore.ts#L58) diff --git a/packages/docs/api/modules/pinia.md b/packages/docs/api/modules/pinia.md index 363bcb98..225f0cf2 100644 --- a/packages/docs/api/modules/pinia.md +++ b/packages/docs/api/modules/pinia.md @@ -33,7 +33,7 @@ sidebarDepth: 3 - [\_StoreWithState](../interfaces/pinia._StoreWithState.md) - [\_SubscriptionCallbackMutationBase](../interfaces/pinia._SubscriptionCallbackMutationBase.md) -## Type aliases +## Type Aliases ### PiniaStorePlugin @@ -41,11 +41,13 @@ sidebarDepth: 3 Plugin to extend every store. -**`deprecated`** use PiniaPlugin instead +**`Deprecated`** + +use PiniaPlugin instead #### Defined in -[packages/pinia/src/rootStore.ts:149](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/rootStore.ts#L149) +[packages/pinia/src/rootStore.ts:149](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/rootStore.ts#L149) ___ @@ -57,13 +59,13 @@ Generic state of a Store #### Defined in -[packages/pinia/src/types.ts:13](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L13) +[packages/pinia/src/types.ts:13](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L13) ___ ### Store -Ƭ **Store**<`Id`, `S`, `G`, `A`\>: [`_StoreWithState`](../interfaces/pinia._StoreWithState.md)<`Id`, `S`, `G`, `A`\> & `UnwrapRef`<`S`\> & [`_StoreWithGetters`](pinia.md#_storewithgetters)<`G`\> & [`_ActionsTree`](pinia.md#_actionstree) extends `A` ? {} : `A` & [`PiniaCustomProperties`](../interfaces/pinia.PiniaCustomProperties.md)<`Id`, `S`, `G`, `A`\> & `PiniaCustomStateProperties`<`S`\> +Ƭ **Store**<`Id`, `S`, `G`, `A`\>: [`_StoreWithState`](../interfaces/pinia._StoreWithState.md)<`Id`, `S`, `G`, `A`\> & `UnwrapRef`<`S`\> & [`_StoreWithGetters`](pinia.md#_storewithgetters)<`G`\> & [`_ActionsTree`](pinia.md#_actionstree) extends `A` ? {} : `A` & [`PiniaCustomProperties`](../interfaces/pinia.PiniaCustomProperties.md)<`Id`, `S`, `G`, `A`\> & [`PiniaCustomStateProperties`](../interfaces/pinia.PiniaCustomStateProperties.md)<`S`\> Store type to build a store. @@ -78,7 +80,7 @@ Store type to build a store. #### Defined in -[packages/pinia/src/types.ts:470](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L470) +[packages/pinia/src/types.ts:463](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L463) ___ @@ -97,7 +99,7 @@ Options Store. #### Defined in -[packages/pinia/src/store.ts:729](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/store.ts#L729) +[packages/pinia/src/store.ts:744](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/store.ts#L744) ___ @@ -111,7 +113,7 @@ about the kind of store that is passed. #### Defined in -[packages/pinia/src/types.ts:489](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L489) +[packages/pinia/src/types.ts:482](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L482) ___ @@ -130,7 +132,7 @@ Options Store. #### Defined in -[packages/pinia/src/store.ts:742](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/store.ts#L742) +[packages/pinia/src/store.ts:757](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/store.ts#L757) ___ @@ -165,7 +167,7 @@ Argument of `store.$onAction()` #### Defined in -[packages/pinia/src/types.ts:243](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L243) +[packages/pinia/src/types.ts:236](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L236) ___ @@ -187,7 +189,7 @@ TODO: should have only the Id, the Store and Actions to generate the proper obje #### Defined in -[packages/pinia/src/types.ts:227](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L227) +[packages/pinia/src/types.ts:220](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L220) ___ @@ -206,7 +208,7 @@ Options Store. Note this unwraps refs. #### Defined in -[packages/pinia/src/store.ts:755](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/store.ts#L755) +[packages/pinia/src/store.ts:770](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/store.ts#L770) ___ @@ -239,7 +241,7 @@ Callback of a subscription #### Defined in -[packages/pinia/src/types.ts:148](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L148) +[packages/pinia/src/types.ts:148](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L148) ___ @@ -257,7 +259,7 @@ Context object passed to a subscription callback. #### Defined in -[packages/pinia/src/types.ts:140](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L140) +[packages/pinia/src/types.ts:140](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L140) ___ @@ -270,7 +272,7 @@ For internal use **only** #### Defined in -[packages/pinia/src/types.ts:555](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L555) +[packages/pinia/src/types.ts:548](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L548) ___ @@ -286,7 +288,7 @@ ___ #### Defined in -[packages/pinia/src/types.ts:164](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L164) +[packages/pinia/src/types.ts:164](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L164) ___ @@ -294,7 +296,7 @@ ___ Ƭ **\_DeepPartial**<`T`\>: { [K in keyof T]?: \_DeepPartial } -Recursive `Partial`. Used by {@link Store.$patch}. +Recursive `Partial`. Used by [['$patch']](pinia.md#store). For internal use **only** @@ -306,7 +308,7 @@ For internal use **only** #### Defined in -[packages/pinia/src/types.ts:35](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L35) +[packages/pinia/src/types.ts:35](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L35) ___ @@ -324,7 +326,7 @@ For internal use **only** #### Defined in -[packages/pinia/src/types.ts:599](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L599) +[packages/pinia/src/types.ts:592](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L592) ___ @@ -343,13 +345,13 @@ For internal use **only** #### Defined in -[packages/pinia/src/types.ts:569](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L569) +[packages/pinia/src/types.ts:562](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L562) ___ ### \_ExtractGettersFromSetupStore -Ƭ **\_ExtractGettersFromSetupStore**<`SS`\>: `SS` extends `undefined` \| `void` ? {} : [`_ExtractGettersFromSetupStore_Keys`](pinia.md#_extractgettersfromsetupstore_keys)<`SS`\> extends keyof `SS` ? [`_UnwrapAll`](pinia.md#_unwrapall)<`Pick`<`SS`, [`_ExtractGettersFromSetupStore_Keys`](pinia.md#_extractgettersfromsetupstore_keys)<`SS`\>\>\> : `never` +Ƭ **\_ExtractGettersFromSetupStore**<`SS`\>: `SS` extends `undefined` \| `void` ? {} : [`_ExtractGettersFromSetupStore_Keys`](pinia.md#_extractgettersfromsetupstore_keys)<`SS`\> extends keyof `SS` ? `Pick`<`SS`, [`_ExtractGettersFromSetupStore_Keys`](pinia.md#_extractgettersfromsetupstore_keys)<`SS`\>\> : `never` For internal use **only** @@ -361,7 +363,7 @@ For internal use **only** #### Defined in -[packages/pinia/src/types.ts:608](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L608) +[packages/pinia/src/types.ts:601](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L601) ___ @@ -380,7 +382,7 @@ For internal use **only** #### Defined in -[packages/pinia/src/types.ts:577](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L577) +[packages/pinia/src/types.ts:570](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L570) ___ @@ -398,7 +400,7 @@ For internal use **only** #### Defined in -[packages/pinia/src/types.ts:590](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L590) +[packages/pinia/src/types.ts:583](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L583) ___ @@ -417,13 +419,13 @@ For internal use **only** #### Defined in -[packages/pinia/src/types.ts:561](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L561) +[packages/pinia/src/types.ts:554](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L554) ___ ### \_GettersTree -Ƭ **\_GettersTree**<`S`\>: `Record`<`string`, (`state`: `UnwrapRef`<`S`\> & `UnwrapRef`<`PiniaCustomStateProperties`<`S`\>\>) => `any` \| () => `any`\> +Ƭ **\_GettersTree**<`S`\>: `Record`<`string`, (`state`: `UnwrapRef`<`S`\> & `UnwrapRef`<[`PiniaCustomStateProperties`](../interfaces/pinia.PiniaCustomStateProperties.md)<`S`\>\>) => `any` \| () => `any`\> Type of an object of Getters that infers the argument. For internal usage only. For internal use **only** @@ -436,7 +438,7 @@ For internal use **only** #### Defined in -[packages/pinia/src/types.ts:545](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L545) +[packages/pinia/src/types.ts:538](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L538) ___ @@ -455,7 +457,7 @@ For internal use **only** #### Defined in -[packages/pinia/src/mapHelpers.ts:297](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/mapHelpers.ts#L297) +[packages/pinia/src/mapHelpers.ts:297](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/mapHelpers.ts#L297) ___ @@ -473,7 +475,7 @@ For internal use **only** #### Defined in -[packages/pinia/src/mapHelpers.ts:290](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/mapHelpers.ts#L290) +[packages/pinia/src/mapHelpers.ts:290](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/mapHelpers.ts#L290) ___ @@ -495,7 +497,7 @@ For internal use **only** #### Defined in -[packages/pinia/src/mapHelpers.ts:141](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/mapHelpers.ts#L141) +[packages/pinia/src/mapHelpers.ts:141](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/mapHelpers.ts#L141) ___ @@ -515,7 +517,7 @@ For internal use **only** #### Defined in -[packages/pinia/src/mapHelpers.ts:125](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/mapHelpers.ts#L125) +[packages/pinia/src/mapHelpers.ts:125](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/mapHelpers.ts#L125) ___ @@ -534,7 +536,7 @@ For internal use **only** #### Defined in -[packages/pinia/src/mapHelpers.ts:422](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/mapHelpers.ts#L422) +[packages/pinia/src/mapHelpers.ts:422](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/mapHelpers.ts#L422) ___ @@ -552,7 +554,7 @@ For internal use **only** #### Defined in -[packages/pinia/src/mapHelpers.ts:412](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/mapHelpers.ts#L412) +[packages/pinia/src/mapHelpers.ts:412](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/mapHelpers.ts#L412) ___ @@ -580,13 +582,13 @@ For internal use **only** #### Defined in -[packages/pinia/src/types.ts:439](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L439) +[packages/pinia/src/types.ts:432](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L432) ___ ### \_Spread -Ƭ **\_Spread**<`A`\>: `A` extends [infer L, ...infer R] ? [`_StoreObject`](pinia.md#_storeobject)<`L`\> & [`_Spread`](pinia.md#_spread)<`R`\> : `unknown` +Ƭ **\_Spread**<`A`\>: `A` extends [infer L, ...(infer R)] ? [`_StoreObject`](pinia.md#_storeobject)<`L`\> & [`_Spread`](pinia.md#_spread)<`R`\> : `unknown` For internal use **only**. @@ -598,7 +600,7 @@ For internal use **only**. #### Defined in -[packages/pinia/src/mapHelpers.ts:53](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/mapHelpers.ts#L53) +[packages/pinia/src/mapHelpers.ts:53](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/mapHelpers.ts#L53) ___ @@ -616,7 +618,7 @@ For internal use **only**. #### Defined in -[packages/pinia/src/mapHelpers.ts:25](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/mapHelpers.ts#L25) +[packages/pinia/src/mapHelpers.ts:25](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/mapHelpers.ts#L25) ___ @@ -635,7 +637,7 @@ For internal use **only** #### Defined in -[packages/pinia/src/types.ts:451](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L451) +[packages/pinia/src/types.ts:444](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L444) ___ @@ -654,7 +656,7 @@ For internal use **only** #### Defined in -[packages/pinia/src/types.ts:461](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L461) +[packages/pinia/src/types.ts:454](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L454) ___ @@ -673,7 +675,7 @@ For internal use **only** #### Defined in -[packages/pinia/src/types.ts:585](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/types.ts#L585) +[packages/pinia/src/types.ts:578](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/types.ts#L578) ## Variables @@ -685,7 +687,8 @@ Vue 2 Plugin that must be installed for pinia to work. Note **you don't need this plugin if you are using Nuxt.js**. Use the `buildModule` instead: https://pinia.vuejs.org/ssr/nuxt.html. -**`example`** +**`Example`** + ```js import Vue from 'vue' import { PiniaVuePlugin, createPinia } from 'pinia' @@ -700,11 +703,13 @@ new Vue({ }) ``` -**`param`** `Vue` imported from 'vue'. +**`Param`** + +`Vue` imported from 'vue'. #### Defined in -[packages/pinia/src/vue2-plugin.ts:28](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/vue2-plugin.ts#L28) +[packages/pinia/src/vue2-plugin.ts:28](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/vue2-plugin.ts#L28) ## Functions @@ -714,7 +719,8 @@ new Vue({ Creates an _accept_ function to pass to `import.meta.hot` in Vite applications. -**`example`** +**`Example`** + ```js const useUser = defineStore(...) if (import.meta.hot) { @@ -747,7 +753,7 @@ if (import.meta.hot) { #### Defined in -[packages/pinia/src/hmr.ts:73](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/hmr.ts#L73) +[packages/pinia/src/hmr.ts:73](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/hmr.ts#L73) ___ @@ -763,7 +769,7 @@ Creates a Pinia instance to be used by the application #### Defined in -[packages/pinia/src/createPinia.ts:10](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/createPinia.ts#L10) +[packages/pinia/src/createPinia.ts:10](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/createPinia.ts#L10) ___ @@ -795,7 +801,7 @@ Creates a `useStore` function that retrieves the store instance #### Defined in -[packages/pinia/src/store.ts:778](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/store.ts#L778) +[packages/pinia/src/store.ts:793](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/store.ts#L793) ▸ **defineStore**<`Id`, `S`, `G`, `A`\>(`options`): [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)<`Id`, `S`, `G`, `A`\> @@ -822,7 +828,7 @@ Creates a `useStore` function that retrieves the store instance #### Defined in -[packages/pinia/src/store.ts:794](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/store.ts#L794) +[packages/pinia/src/store.ts:809](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/store.ts#L809) ▸ **defineStore**<`Id`, `SS`\>(`id`, `storeSetup`, `options?`): [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)<`Id`, [`_ExtractStateFromSetupStore`](pinia.md#_extractstatefromsetupstore)<`SS`\>, [`_ExtractGettersFromSetupStore`](pinia.md#_extractgettersfromsetupstore)<`SS`\>, [`_ExtractActionsFromSetupStore`](pinia.md#_extractactionsfromsetupstore)<`SS`\>\> @@ -849,7 +855,7 @@ Creates a `useStore` function that retrieves the store instance #### Defined in -[packages/pinia/src/store.ts:809](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/store.ts#L809) +[packages/pinia/src/store.ts:824](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/store.ts#L824) ___ @@ -865,7 +871,7 @@ Get the currently active pinia if there is any. #### Defined in -[packages/pinia/src/rootStore.ts:39](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/rootStore.ts#L39) +[packages/pinia/src/rootStore.ts:39](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/rootStore.ts#L39) ___ @@ -878,7 +884,8 @@ API (`setup()`) by generating an object to be spread in the `methods` field of a component. The values of the object are the actions while the keys are the names of the resulting methods. -**`example`** +**`Example`** + ```js export default { methods: { @@ -917,7 +924,7 @@ export default { #### Defined in -[packages/pinia/src/mapHelpers.ts:326](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/mapHelpers.ts#L326) +[packages/pinia/src/mapHelpers.ts:326](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/mapHelpers.ts#L326) ▸ **mapActions**<`Id`, `S`, `G`, `A`\>(`useStore`, `keys`): [`_MapActionsReturn`](pinia.md#_mapactionsreturn)<`A`\> @@ -925,7 +932,8 @@ Allows directly using actions from your store without using the composition API (`setup()`) by generating an object to be spread in the `methods` field of a component. -**`example`** +**`Example`** + ```js export default { methods: { @@ -962,7 +970,7 @@ export default { #### Defined in -[packages/pinia/src/mapHelpers.ts:359](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/mapHelpers.ts#L359) +[packages/pinia/src/mapHelpers.ts:359](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/mapHelpers.ts#L359) ___ @@ -970,9 +978,38 @@ ___ ▸ **mapGetters**<`Id`, `S`, `G`, `A`, `KeyMapper`\>(`useStore`, `keyMapper`): [`_MapStateObjectReturn`](pinia.md#_mapstateobjectreturn)<`Id`, `S`, `G`, `A`, `KeyMapper`\> -Alias for `mapState()`. You should use `mapState()` instead. +Allows using state and getters from one store without using the composition +API (`setup()`) by generating an object to be spread in the `computed` field +of a component. The values of the object are the state properties/getters +while the keys are the names of the resulting computed properties. +Optionally, you can also pass a custom function that will receive the store +as its first argument. Note that while it has access to the component +instance via `this`, it won't be typed. -**`deprecated`** use `mapState()` instead. +**`Example`** + +```js +export default { + computed: { + // other computed properties + // useCounterStore has a state property named `count` and a getter `double` + ...mapState(useCounterStore, { + n: 'count', + triple: store => store.n * 3, + // note we can't use an arrow function if we want to use `this` + custom(store) { + return this.someComponentValue + store.n + }, + doubleN: 'double' + }) + }, + + created() { + this.n // 2 + this.doubleN // 4 + } +} +``` #### Type parameters @@ -986,10 +1023,10 @@ Alias for `mapState()`. You should use `mapState()` instead. #### Parameters -| Name | Type | -| :------ | :------ | -| `useStore` | [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)<`Id`, `S`, `G`, `A`\> | -| `keyMapper` | `KeyMapper` | +| Name | Type | Description | +| :------ | :------ | :------ | +| `useStore` | [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)<`Id`, `S`, `G`, `A`\> | store to map from | +| `keyMapper` | `KeyMapper` | object of state properties or getters | #### Returns @@ -997,13 +1034,29 @@ Alias for `mapState()`. You should use `mapState()` instead. #### Defined in -[packages/pinia/src/mapHelpers.ts:285](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/mapHelpers.ts#L285) +[packages/pinia/src/mapHelpers.ts:194](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/mapHelpers.ts#L194) ▸ **mapGetters**<`Id`, `S`, `G`, `A`, `Keys`\>(`useStore`, `keys`): [`_MapStateReturn`](pinia.md#_mapstatereturn)<`S`, `G`, `Keys`\> -Alias for `mapState()`. You should use `mapState()` instead. +Allows using state and getters from one store without using the composition +API (`setup()`) by generating an object to be spread in the `computed` field +of a component. -**`deprecated`** use `mapState()` instead. +**`Example`** + +```js +export default { + computed: { + // other computed properties + ...mapState(useCounterStore, ['count', 'double']) + }, + + created() { + this.count // 2 + this.double // 4 + } +} +``` #### Type parameters @@ -1017,10 +1070,10 @@ Alias for `mapState()`. You should use `mapState()` instead. #### Parameters -| Name | Type | -| :------ | :------ | -| `useStore` | [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)<`Id`, `S`, `G`, `A`\> | -| `keys` | readonly `Keys`[] | +| Name | Type | Description | +| :------ | :------ | :------ | +| `useStore` | [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)<`Id`, `S`, `G`, `A`\> | store to map from | +| `keys` | readonly `Keys`[] | array of state properties or getters | #### Returns @@ -1028,7 +1081,7 @@ Alias for `mapState()`. You should use `mapState()` instead. #### Defined in -[packages/pinia/src/mapHelpers.ts:285](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/mapHelpers.ts#L285) +[packages/pinia/src/mapHelpers.ts:231](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/mapHelpers.ts#L231) ___ @@ -1044,7 +1097,8 @@ Optionally, you can also pass a custom function that will receive the store as its first argument. Note that while it has access to the component instance via `this`, it won't be typed. -**`example`** +**`Example`** + ```js export default { computed: { @@ -1091,7 +1145,7 @@ export default { #### Defined in -[packages/pinia/src/mapHelpers.ts:194](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/mapHelpers.ts#L194) +[packages/pinia/src/mapHelpers.ts:194](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/mapHelpers.ts#L194) ▸ **mapState**<`Id`, `S`, `G`, `A`, `Keys`\>(`useStore`, `keys`): [`_MapStateReturn`](pinia.md#_mapstatereturn)<`S`, `G`, `Keys`\> @@ -1099,7 +1153,8 @@ Allows using state and getters from one store without using the composition API (`setup()`) by generating an object to be spread in the `computed` field of a component. -**`example`** +**`Example`** + ```js export default { computed: { @@ -1137,7 +1192,7 @@ export default { #### Defined in -[packages/pinia/src/mapHelpers.ts:231](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/mapHelpers.ts#L231) +[packages/pinia/src/mapHelpers.ts:231](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/mapHelpers.ts#L231) ___ @@ -1149,7 +1204,8 @@ Allows using stores without the composition API (`setup()`) by generating an object to be spread in the `computed` field of a component. It accepts a list of store definitions. -**`example`** +**`Example`** + ```js export default { computed: { @@ -1182,7 +1238,7 @@ export default { #### Defined in -[packages/pinia/src/mapHelpers.ts:96](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/mapHelpers.ts#L96) +[packages/pinia/src/mapHelpers.ts:96](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/mapHelpers.ts#L96) ___ @@ -1217,7 +1273,7 @@ added. #### Defined in -[packages/pinia/src/mapHelpers.ts:440](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/mapHelpers.ts#L440) +[packages/pinia/src/mapHelpers.ts:440](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/mapHelpers.ts#L440) ▸ **mapWritableState**<`Id`, `S`, `G`, `A`\>(`useStore`, `keys`): [`_MapWritableStateReturn`](pinia.md#_mapwritablestatereturn)<`S`\> @@ -1247,7 +1303,7 @@ of a component. #### Defined in -[packages/pinia/src/mapHelpers.ts:458](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/mapHelpers.ts#L458) +[packages/pinia/src/mapHelpers.ts:458](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/mapHelpers.ts#L458) ___ @@ -1270,7 +1326,7 @@ actions and getters #### Defined in -[packages/pinia/src/rootStore.ts:33](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/rootStore.ts#L33) +[packages/pinia/src/rootStore.ts:33](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/rootStore.ts#L33) ___ @@ -1280,7 +1336,7 @@ ___ Changes the suffix added by `mapStores()`. Can be set to an empty string. Defaults to `"Store"`. Make sure to extend the MapStoresCustomization -interface if you need are using TypeScript. +interface if you are using TypeScript. #### Parameters @@ -1294,7 +1350,7 @@ interface if you need are using TypeScript. #### Defined in -[packages/pinia/src/mapHelpers.ts:66](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/mapHelpers.ts#L66) +[packages/pinia/src/mapHelpers.ts:66](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/mapHelpers.ts#L66) ___ @@ -1302,6 +1358,9 @@ ___ ▸ **skipHydrate**<`T`\>(`obj`): `T` +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. + #### Type parameters | Name | Type | @@ -1310,17 +1369,19 @@ ___ #### Parameters -| Name | Type | -| :------ | :------ | -| `obj` | `T` | +| Name | Type | Description | +| :------ | :------ | :------ | +| `obj` | `T` | target object | #### Returns `T` +obj + #### Defined in -[packages/pinia/src/store.ts:87](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/store.ts#L87) +[packages/pinia/src/store.ts:94](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/store.ts#L94) ___ @@ -1337,7 +1398,7 @@ completely ignored. | Name | Type | | :------ | :------ | -| `SS` | extends [`_StoreWithState`](../interfaces/pinia._StoreWithState.md)<`string`, [`StateTree`](pinia.md#statetree), [`_GettersTree`](pinia.md#_getterstree)<[`StateTree`](pinia.md#statetree)\>, [`_ActionsTree`](pinia.md#_actionstree), `SS`\> & {} & [`_StoreWithGetters`](pinia.md#_storewithgetters)<[`_GettersTree`](pinia.md#_getterstree)<[`StateTree`](pinia.md#statetree)\>\> & [`PiniaCustomProperties`](../interfaces/pinia.PiniaCustomProperties.md)<`string`, [`StateTree`](pinia.md#statetree), [`_GettersTree`](pinia.md#_getterstree)<[`StateTree`](pinia.md#statetree)\>, [`_ActionsTree`](pinia.md#_actionstree), `SS`\> & `PiniaCustomStateProperties`<[`StateTree`](pinia.md#statetree), `SS`\> | +| `SS` | extends [`_StoreWithState`](../interfaces/pinia._StoreWithState.md)<`string`, [`StateTree`](pinia.md#statetree), [`_GettersTree`](pinia.md#_getterstree)<[`StateTree`](pinia.md#statetree)\>, [`_ActionsTree`](pinia.md#_actionstree), `SS`\> & [`StateTree`](pinia.md#statetree) & [`_StoreWithGetters`](pinia.md#_storewithgetters)<[`_GettersTree`](pinia.md#_getterstree)<[`StateTree`](pinia.md#statetree)\>\> & [`PiniaCustomProperties`](../interfaces/pinia.PiniaCustomProperties.md)<`string`, [`StateTree`](pinia.md#statetree), [`_GettersTree`](pinia.md#_getterstree)<[`StateTree`](pinia.md#statetree)\>, [`_ActionsTree`](pinia.md#_actionstree), `SS`\> & [`PiniaCustomStateProperties`](../interfaces/pinia.PiniaCustomStateProperties.md)<[`StateTree`](pinia.md#statetree), `SS`\> | #### Parameters @@ -1351,4 +1412,4 @@ completely ignored. #### Defined in -[packages/pinia/src/storeToRefs.ts:21](https://github.com/vuejs/pinia/blob/2b998ee/packages/pinia/src/storeToRefs.ts#L21) +[packages/pinia/src/storeToRefs.ts:21](https://github.com/vuejs/pinia/blob/aa0192a/packages/pinia/src/storeToRefs.ts#L21) diff --git a/packages/docs/api/modules/pinia_nuxt.md b/packages/docs/api/modules/pinia_nuxt.md index 9a7ec555..74efd7ff 100644 --- a/packages/docs/api/modules/pinia_nuxt.md +++ b/packages/docs/api/modules/pinia_nuxt.md @@ -10,20 +10,21 @@ sidebarDepth: 3 ## Interfaces -- [PiniaNuxtOptions](../interfaces/pinia_nuxt.PiniaNuxtOptions.md) +- [ModuleOptions](../interfaces/pinia_nuxt.ModuleOptions.md) ## Functions ### default -▸ **default**(`this`, `moduleOptions`): `void` \| `Promise`<`void`\> +▸ **default**(`this`, `inlineOptions`, `nuxt`): `void` \| `Promise`<`void`\> #### Parameters | Name | Type | | :------ | :------ | -| `this` | `ModuleThis` | -| `moduleOptions` | `any` | +| `this` | `void` | +| `inlineOptions` | [`ModuleOptions`](../interfaces/pinia_nuxt.ModuleOptions.md) | +| `nuxt` | `Nuxt` | #### Returns @@ -31,4 +32,4 @@ sidebarDepth: 3 #### Defined in -node_modules/.pnpm/@nuxt+types@2.15.8/node_modules/@nuxt/types/config/module.d.ts:29 +node_modules/.pnpm/@nuxt+schema@3.0.0-rc.4/node_modules/@nuxt/schema/dist/index.d.ts:470 diff --git a/packages/docs/api/modules/pinia_testing.md b/packages/docs/api/modules/pinia_testing.md index 7399b71a..56d3cc7b 100644 --- a/packages/docs/api/modules/pinia_testing.md +++ b/packages/docs/api/modules/pinia_testing.md @@ -40,4 +40,4 @@ a augmented pinia instance #### Defined in -[packages/testing/src/testing.ts:92](https://github.com/vuejs/pinia/blob/2b998ee/packages/testing/src/testing.ts#L92) +[packages/testing/src/testing.ts:92](https://github.com/vuejs/pinia/blob/aa0192a/packages/testing/src/testing.ts#L92) -- 2.47.2