From: Eduardo San Martin Morote Date: Thu, 3 Aug 2023 08:20:45 +0000 (+0200) Subject: docs: api updates X-Git-Tag: @pinia/nuxt@0.5.0~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a192bee700ee53fae9538a98c3e0a464f2d18b7;p=thirdparty%2Fvuejs%2Fpinia.git docs: api updates --- diff --git a/packages/docs/api/enums/pinia.MutationType.md b/packages/docs/api/enums/pinia.MutationType.md index 6c68f38d..5f2b7fd4 100644 --- a/packages/docs/api/enums/pinia.MutationType.md +++ b/packages/docs/api/enums/pinia.MutationType.md @@ -10,9 +10,9 @@ editLink: false Possible types for SubscriptionCallback -## Enumeration Members %{#Enumeration-Members}% +## Enumeration Members -### direct %{#Enumeration-Members-direct}% +### direct • **direct** = ``"direct"`` @@ -24,7 +24,7 @@ Direct mutation of the state: ___ -### patchFunction %{#Enumeration-Members-patchFunction}% +### patchFunction • **patchFunction** = ``"patch function"`` @@ -34,7 +34,7 @@ Mutated the state with `$patch` and a function ___ -### patchObject %{#Enumeration-Members-patchObject}% +### patchObject • **patchObject** = ``"patch object"`` diff --git a/packages/docs/api/index.md b/packages/docs/api/index.md index e331e7e9..4bf4c87f 100644 --- a/packages/docs/api/index.md +++ b/packages/docs/api/index.md @@ -1,8 +1,12 @@ +--- +editLink: false +--- + API Documentation # API Documentation -## Modules %{#Modules}% +## Modules - [@pinia/nuxt](modules/pinia_nuxt.md) - [@pinia/testing](modules/pinia_testing.md) diff --git a/packages/docs/api/interfaces/pinia.DefineSetupStoreOptions.md b/packages/docs/api/interfaces/pinia.DefineSetupStoreOptions.md index a95ef29a..0746ac6e 100644 --- a/packages/docs/api/interfaces/pinia.DefineSetupStoreOptions.md +++ b/packages/docs/api/interfaces/pinia.DefineSetupStoreOptions.md @@ -15,7 +15,7 @@ augment stores with the plugin API. [DefineStoreOptionsBase](pinia.DefineStoreOptionsBase.md). -## Type parameters %{#Type-parameters}% +## Type parameters | Name | Type | | :------ | :------ | @@ -24,15 +24,15 @@ augment stores with the plugin API. | `G` | `G` | | `A` | `A` | -## Hierarchy %{#Hierarchy}% +## Hierarchy - [`DefineStoreOptionsBase`](pinia.DefineStoreOptionsBase.md)<`S`, [`Store`](../modules/pinia.md#store)<`Id`, `S`, `G`, `A`\>\> ↳ **`DefineSetupStoreOptions`** -## Properties %{#Properties}% +## Properties -### actions %{#Properties-actions}% +### actions • `Optional` **actions**: `A` diff --git a/packages/docs/api/interfaces/pinia.DefineStoreOptions.md b/packages/docs/api/interfaces/pinia.DefineStoreOptions.md index ba20a033..f89955fd 100644 --- a/packages/docs/api/interfaces/pinia.DefineStoreOptions.md +++ b/packages/docs/api/interfaces/pinia.DefineStoreOptions.md @@ -15,7 +15,7 @@ augment stores with the plugin API. [DefineStoreOptionsBase](pinia.DefineStoreOptionsBase.md). -## Type parameters %{#Type-parameters}% +## Type parameters | Name | Type | | :------ | :------ | @@ -24,15 +24,15 @@ augment stores with the plugin API. | `G` | `G` | | `A` | `A` | -## Hierarchy %{#Hierarchy}% +## Hierarchy - [`DefineStoreOptionsBase`](pinia.DefineStoreOptionsBase.md)<`S`, [`Store`](../modules/pinia.md#store)<`Id`, `S`, `G`, `A`\>\> ↳ **`DefineStoreOptions`** -## Properties %{#Properties}% +## Properties -### actions %{#Properties-actions}% +### actions • `Optional` **actions**: `A` & `ThisType`<`A` & `UnwrapRef`<`S`\> & [`_StoreWithState`](pinia._StoreWithState.md)<`Id`, `S`, `G`, `A`\> & [`_StoreWithGetters`](../modules/pinia.md#_storewithgetters)<`G`\> & [`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)\>\> @@ -40,7 +40,7 @@ Optional object of actions. ___ -### getters %{#Properties-getters}% +### getters • `Optional` **getters**: `G` & `ThisType`<`UnwrapRef`<`S`\> & [`_StoreWithGetters`](../modules/pinia.md#_storewithgetters)<`G`\> & [`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)\>\> & [`_GettersTree`](../modules/pinia.md#_getterstree)<`S`\> @@ -48,7 +48,7 @@ Optional object of getters. ___ -### id %{#Properties-id}% +### id • **id**: `Id` @@ -56,30 +56,41 @@ Unique string key to identify the store across the application. ___ -### state %{#Properties-state}% +### state • `Optional` **state**: () => `S` -#### Type declaration %{#Properties-state-Type-declaration}% +#### Type declaration ▸ (): `S` Function to create a fresh state. **Must be an arrow function** to ensure correct typings! -##### Returns %{#Properties-state-Type-declaration-Returns}% +##### Returns `S` -## Methods %{#Methods}% +## Methods -### hydrate %{#Methods-hydrate}% +### hydrate ▸ `Optional` **hydrate**(`storeState`, `initialState`): `void` 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. +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `storeState` | `UnwrapRef`<`S`\> | the current state in the store | +| `initialState` | `UnwrapRef`<`S`\> | initialState | + +#### Returns + +`void` + **`Example`** If in your `state`, you use any `customRef`s, any `computed`s, or any `ref`s that have a different value on @@ -97,14 +108,3 @@ const useStore = defineStore('main', { } }) ``` - -#### Parameters %{#Methods-hydrate-Parameters}% - -| Name | Type | Description | -| :------ | :------ | :------ | -| `storeState` | `UnwrapRef`<`S`\> | the current state in the store | -| `initialState` | `UnwrapRef`<`S`\> | initialState | - -#### Returns %{#Methods-hydrate-Returns}% - -`void` diff --git a/packages/docs/api/interfaces/pinia.DefineStoreOptionsBase.md b/packages/docs/api/interfaces/pinia.DefineStoreOptionsBase.md index 389e56e9..c6fbadba 100644 --- a/packages/docs/api/interfaces/pinia.DefineStoreOptionsBase.md +++ b/packages/docs/api/interfaces/pinia.DefineStoreOptionsBase.md @@ -12,14 +12,14 @@ Options passed to `defineStore()` that are common between option and setup stores. Extend this interface if you want to add custom options to both kinds of stores. -## Type parameters %{#Type-parameters}% +## Type parameters | Name | Type | | :------ | :------ | | `S` | extends [`StateTree`](../modules/pinia.md#statetree) | | `Store` | `Store` | -## Hierarchy %{#Hierarchy}% +## Hierarchy - **`DefineStoreOptionsBase`** diff --git a/packages/docs/api/interfaces/pinia.DefineStoreOptionsInPlugin.md b/packages/docs/api/interfaces/pinia.DefineStoreOptionsInPlugin.md index 44196364..e6bac956 100644 --- a/packages/docs/api/interfaces/pinia.DefineStoreOptionsInPlugin.md +++ b/packages/docs/api/interfaces/pinia.DefineStoreOptionsInPlugin.md @@ -10,7 +10,7 @@ editLink: false Available `options` when creating a pinia plugin. -## Type parameters %{#Type-parameters}% +## Type parameters | Name | Type | | :------ | :------ | @@ -19,15 +19,15 @@ Available `options` when creating a pinia plugin. | `G` | `G` | | `A` | `A` | -## Hierarchy %{#Hierarchy}% +## Hierarchy - `Omit`<[`DefineStoreOptions`](pinia.DefineStoreOptions.md)<`Id`, `S`, `G`, `A`\>, ``"id"`` \| ``"actions"``\> ↳ **`DefineStoreOptionsInPlugin`** -## Properties %{#Properties}% +## Properties -### actions %{#Properties-actions}% +### actions • **actions**: `A` @@ -37,46 +37,57 @@ Defaults to an empty object if no actions are defined. ___ -### getters %{#Properties-getters}% +### getters • `Optional` **getters**: `G` & `ThisType`<`UnwrapRef`<`S`\> & [`_StoreWithGetters`](../modules/pinia.md#_storewithgetters)<`G`\> & [`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)\>\> & [`_GettersTree`](../modules/pinia.md#_getterstree)<`S`\> Optional object of getters. -#### Inherited from %{#Properties-getters-Inherited-from}% +#### Inherited from Omit.getters ___ -### state %{#Properties-state}% +### state • `Optional` **state**: () => `S` -#### Type declaration %{#Properties-state-Type-declaration}% +#### Type declaration ▸ (): `S` Function to create a fresh state. **Must be an arrow function** to ensure correct typings! -##### Returns %{#Properties-state-Type-declaration-Returns}% +##### Returns `S` -#### Inherited from %{#Properties-state-Inherited-from}% +#### Inherited from Omit.state -## Methods %{#Methods}% +## Methods -### hydrate %{#Methods-hydrate}% +### hydrate ▸ `Optional` **hydrate**(`storeState`, `initialState`): `void` 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. +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `storeState` | `UnwrapRef`<`S`\> | the current state in the store | +| `initialState` | `UnwrapRef`<`S`\> | initialState | + +#### Returns + +`void` + **`Example`** If in your `state`, you use any `customRef`s, any `computed`s, or any `ref`s that have a different value on @@ -95,17 +106,6 @@ const useStore = defineStore('main', { }) ``` -#### Parameters %{#Methods-hydrate-Parameters}% - -| Name | Type | Description | -| :------ | :------ | :------ | -| `storeState` | `UnwrapRef`<`S`\> | the current state in the store | -| `initialState` | `UnwrapRef`<`S`\> | initialState | - -#### Returns %{#Methods-hydrate-Returns}% - -`void` - -#### Inherited from %{#Methods-hydrate-Inherited-from}% +#### Inherited from Omit.hydrate diff --git a/packages/docs/api/interfaces/pinia.Pinia.md b/packages/docs/api/interfaces/pinia.Pinia.md index f526af0e..7dddf2f6 100644 --- a/packages/docs/api/interfaces/pinia.Pinia.md +++ b/packages/docs/api/interfaces/pinia.Pinia.md @@ -10,54 +10,54 @@ editLink: false Every application must own its own pinia to be able to create stores -## Hierarchy %{#Hierarchy}% +## Hierarchy - **`Pinia`** ↳ [`TestingPinia`](pinia_testing.TestingPinia.md) -## Properties %{#Properties}% +## Properties -### install %{#Properties-install}% +### install • **install**: (`app`: `App`<`any`\>) => `void` -#### Type declaration %{#Properties-install-Type-declaration}% +#### Type declaration ▸ (`app`): `void` -##### Parameters %{#Properties-install-Type-declaration-Parameters}% +##### Parameters | Name | Type | | :------ | :------ | | `app` | `App`<`any`\> | -##### Returns %{#Properties-install-Type-declaration-Returns}% +##### Returns `void` ___ -### state %{#Properties-state}% +### state • **state**: `Ref`<`Record`<`string`, [`StateTree`](../modules/pinia.md#statetree)\>\> root state -## Methods %{#Methods}% +## Methods -### use %{#Methods-use}% +### use ▸ **use**(`plugin`): [`Pinia`](pinia.Pinia.md) Adds a store plugin to extend every store -#### Parameters %{#Methods-use-Parameters}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `plugin` | [`PiniaPlugin`](pinia.PiniaPlugin.md) | store plugin to add | -#### Returns %{#Methods-use-Returns}% +#### Returns [`Pinia`](pinia.Pinia.md) diff --git a/packages/docs/api/interfaces/pinia.PiniaCustomProperties.md b/packages/docs/api/interfaces/pinia.PiniaCustomProperties.md index 1250bdd0..9fb7e21e 100644 --- a/packages/docs/api/interfaces/pinia.PiniaCustomProperties.md +++ b/packages/docs/api/interfaces/pinia.PiniaCustomProperties.md @@ -10,7 +10,7 @@ editLink: false Interface to be extended by the user when they add properties through plugins. -## Type parameters %{#Type-parameters}% +## Type parameters | Name | Type | | :------ | :------ | diff --git a/packages/docs/api/interfaces/pinia.PiniaCustomStateProperties.md b/packages/docs/api/interfaces/pinia.PiniaCustomStateProperties.md index 1c7d8e7d..db838f88 100644 --- a/packages/docs/api/interfaces/pinia.PiniaCustomStateProperties.md +++ b/packages/docs/api/interfaces/pinia.PiniaCustomStateProperties.md @@ -10,7 +10,7 @@ editLink: false Properties that are added to every `store.$state` by `pinia.use()`. -## Type parameters %{#Type-parameters}% +## Type parameters | Name | Type | | :------ | :------ | diff --git a/packages/docs/api/interfaces/pinia.PiniaPlugin.md b/packages/docs/api/interfaces/pinia.PiniaPlugin.md index 3197fe5d..2348345c 100644 --- a/packages/docs/api/interfaces/pinia.PiniaPlugin.md +++ b/packages/docs/api/interfaces/pinia.PiniaPlugin.md @@ -10,21 +10,21 @@ editLink: false Plugin to extend every store. -## Callable %{#Callable}% +## Callable -### PiniaPlugin %{#Callable-PiniaPlugin}% +### 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`](pinia.PiniaCustomStateProperties.md)<[`StateTree`](../modules/pinia.md#statetree)\>\> Plugin to extend every store. Returns an object to extend the store or nothing. -#### Parameters %{#Callable-PiniaPlugin-Parameters}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `context` | [`PiniaPluginContext`](pinia.PiniaPluginContext.md)<`string`, [`StateTree`](../modules/pinia.md#statetree), [`_GettersTree`](../modules/pinia.md#_getterstree)<[`StateTree`](../modules/pinia.md#statetree)\>, [`_ActionsTree`](../modules/pinia.md#_actionstree)\> | Context | -#### Returns %{#Callable-PiniaPlugin-Returns}% +#### 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`](pinia.PiniaCustomStateProperties.md)<[`StateTree`](../modules/pinia.md#statetree)\>\> diff --git a/packages/docs/api/interfaces/pinia.PiniaPluginContext.md b/packages/docs/api/interfaces/pinia.PiniaPluginContext.md index b4b47a02..7fba91d4 100644 --- a/packages/docs/api/interfaces/pinia.PiniaPluginContext.md +++ b/packages/docs/api/interfaces/pinia.PiniaPluginContext.md @@ -10,7 +10,7 @@ editLink: false Context argument passed to Pinia plugins. -## Type parameters %{#Type-parameters}% +## Type parameters | Name | Type | | :------ | :------ | @@ -19,9 +19,9 @@ Context argument passed to Pinia plugins. | `G` | [`_GettersTree`](../modules/pinia.md#_getterstree)<`S`\> | | `A` | [`_ActionsTree`](../modules/pinia.md#_actionstree) | -## Properties %{#Properties}% +## Properties -### app %{#Properties-app}% +### app • **app**: `App`<`any`\> @@ -29,7 +29,7 @@ Current app created with `Vue.createApp()`. ___ -### options %{#Properties-options}% +### options • **options**: [`DefineStoreOptionsInPlugin`](pinia.DefineStoreOptionsInPlugin.md)<`Id`, `S`, `G`, `A`\> @@ -37,7 +37,7 @@ Initial options defining the store when calling `defineStore()`. ___ -### pinia %{#Properties-pinia}% +### pinia • **pinia**: [`Pinia`](pinia.Pinia.md) @@ -45,7 +45,7 @@ pinia instance. ___ -### store %{#Properties-store}% +### store • **store**: [`Store`](../modules/pinia.md#store)<`Id`, `S`, `G`, `A`\> diff --git a/packages/docs/api/interfaces/pinia.StoreDefinition.md b/packages/docs/api/interfaces/pinia.StoreDefinition.md index abde1c9d..97fae150 100644 --- a/packages/docs/api/interfaces/pinia.StoreDefinition.md +++ b/packages/docs/api/interfaces/pinia.StoreDefinition.md @@ -10,7 +10,7 @@ editLink: false Return type of `defineStore()`. Function that allows instantiating a store. -## Type parameters %{#Type-parameters}% +## Type parameters | Name | Type | | :------ | :------ | @@ -19,28 +19,28 @@ Return type of `defineStore()`. Function that allows instantiating a store. | `G` | [`_GettersTree`](../modules/pinia.md#_getterstree)<`S`\> | | `A` | [`_ActionsTree`](../modules/pinia.md#_actionstree) | -## Callable %{#Callable}% +## Callable -### StoreDefinition %{#Callable-StoreDefinition}% +### StoreDefinition ▸ **StoreDefinition**(`pinia?`, `hot?`): [`Store`](../modules/pinia.md#store)<`Id`, `S`, `G`, `A`\> Returns a store, creates it if necessary. -#### Parameters %{#Callable-StoreDefinition-Parameters}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `pinia?` | ``null`` \| [`Pinia`](pinia.Pinia.md) | Pinia instance to retrieve the store | | `hot?` | [`StoreGeneric`](../modules/pinia.md#storegeneric) | dev only hot module replacement | -#### Returns %{#Callable-StoreDefinition-Returns}% +#### Returns [`Store`](../modules/pinia.md#store)<`Id`, `S`, `G`, `A`\> -## Properties %{#Properties}% +## Properties -### $id %{#Properties-$id}% +### $id • **$id**: `Id` diff --git a/packages/docs/api/interfaces/pinia.StoreProperties.md b/packages/docs/api/interfaces/pinia.StoreProperties.md index 64de5337..2c84d45b 100644 --- a/packages/docs/api/interfaces/pinia.StoreProperties.md +++ b/packages/docs/api/interfaces/pinia.StoreProperties.md @@ -10,21 +10,21 @@ editLink: false Properties of a store. -## Type parameters %{#Type-parameters}% +## Type parameters | Name | Type | | :------ | :------ | | `Id` | extends `string` | -## Hierarchy %{#Hierarchy}% +## Hierarchy - **`StoreProperties`** ↳ [`_StoreWithState`](pinia._StoreWithState.md) -## Properties %{#Properties}% +## Properties -### $id %{#Properties-$id}% +### $id • **$id**: `Id` @@ -32,7 +32,7 @@ Unique identifier of the store ___ -### \_customProperties %{#Properties-_customProperties}% +### \_customProperties • **\_customProperties**: `Set`<`string`\> diff --git a/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationDirect.md b/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationDirect.md index b87e0f5c..b9f0226d 100644 --- a/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationDirect.md +++ b/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationDirect.md @@ -12,15 +12,15 @@ Context passed to a subscription callback when directly mutating the state of a store with `store.someState = newValue` or `store.$state.someState = newValue`. -## Hierarchy %{#Hierarchy}% +## Hierarchy - [`_SubscriptionCallbackMutationBase`](pinia._SubscriptionCallbackMutationBase.md) ↳ **`SubscriptionCallbackMutationDirect`** -## Properties %{#Properties}% +## Properties -### events %{#Properties-events}% +### events • **events**: `DebuggerEvent` @@ -28,30 +28,30 @@ newValue`. https://vuejs.org/guide/extras/reactivity-in-depth.html#reactivity-debugging and allows to track mutations in devtools and plugins **during development only**. -#### Overrides %{#Properties-events-Overrides}% +#### Overrides [_SubscriptionCallbackMutationBase](pinia._SubscriptionCallbackMutationBase.md).[events](pinia._SubscriptionCallbackMutationBase.md#events) ___ -### storeId %{#Properties-storeId}% +### storeId • **storeId**: `string` `id` of the store doing the mutation. -#### Inherited from %{#Properties-storeId-Inherited-from}% +#### Inherited from [_SubscriptionCallbackMutationBase](pinia._SubscriptionCallbackMutationBase.md).[storeId](pinia._SubscriptionCallbackMutationBase.md#storeid) ___ -### type %{#Properties-type}% +### type • **type**: [`direct`](../enums/pinia.MutationType.md#direct) Type of the mutation. -#### Overrides %{#Properties-type-Overrides}% +#### Overrides [_SubscriptionCallbackMutationBase](pinia._SubscriptionCallbackMutationBase.md).[type](pinia._SubscriptionCallbackMutationBase.md#type) diff --git a/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchFunction.md b/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchFunction.md index 8a934592..d2d48d49 100644 --- a/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchFunction.md +++ b/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchFunction.md @@ -11,15 +11,15 @@ editLink: false Context passed to a subscription callback when `store.$patch()` is called with a function. -## Hierarchy %{#Hierarchy}% +## Hierarchy - [`_SubscriptionCallbackMutationBase`](pinia._SubscriptionCallbackMutationBase.md) ↳ **`SubscriptionCallbackMutationPatchFunction`** -## Properties %{#Properties}% +## Properties -### events %{#Properties-events}% +### events • **events**: `DebuggerEvent`[] @@ -27,30 +27,30 @@ with a function. https://vuejs.org/guide/extras/reactivity-in-depth.html#reactivity-debugging and allows to track mutations in devtools and plugins **during development only**. -#### Overrides %{#Properties-events-Overrides}% +#### Overrides [_SubscriptionCallbackMutationBase](pinia._SubscriptionCallbackMutationBase.md).[events](pinia._SubscriptionCallbackMutationBase.md#events) ___ -### storeId %{#Properties-storeId}% +### storeId • **storeId**: `string` `id` of the store doing the mutation. -#### Inherited from %{#Properties-storeId-Inherited-from}% +#### Inherited from [_SubscriptionCallbackMutationBase](pinia._SubscriptionCallbackMutationBase.md).[storeId](pinia._SubscriptionCallbackMutationBase.md#storeid) ___ -### type %{#Properties-type}% +### type • **type**: [`patchFunction`](../enums/pinia.MutationType.md#patchfunction) Type of the mutation. -#### Overrides %{#Properties-type-Overrides}% +#### Overrides [_SubscriptionCallbackMutationBase](pinia._SubscriptionCallbackMutationBase.md).[type](pinia._SubscriptionCallbackMutationBase.md#type) diff --git a/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchObject.md b/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchObject.md index 041f0e97..7457ef19 100644 --- a/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchObject.md +++ b/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchObject.md @@ -11,21 +11,21 @@ editLink: false Context passed to a subscription callback when `store.$patch()` is called with an object. -## Type parameters %{#Type-parameters}% +## Type parameters | Name | | :------ | | `S` | -## Hierarchy %{#Hierarchy}% +## Hierarchy - [`_SubscriptionCallbackMutationBase`](pinia._SubscriptionCallbackMutationBase.md) ↳ **`SubscriptionCallbackMutationPatchObject`** -## Properties %{#Properties}% +## Properties -### events %{#Properties-events}% +### events • **events**: `DebuggerEvent`[] @@ -33,13 +33,13 @@ with an object. https://vuejs.org/guide/extras/reactivity-in-depth.html#reactivity-debugging and allows to track mutations in devtools and plugins **during development only**. -#### Overrides %{#Properties-events-Overrides}% +#### Overrides [_SubscriptionCallbackMutationBase](pinia._SubscriptionCallbackMutationBase.md).[events](pinia._SubscriptionCallbackMutationBase.md#events) ___ -### payload %{#Properties-payload}% +### payload • **payload**: [`_DeepPartial`](../modules/pinia.md#_deeppartial)<`S`\> @@ -47,24 +47,24 @@ Object passed to `store.$patch()`. ___ -### storeId %{#Properties-storeId}% +### storeId • **storeId**: `string` `id` of the store doing the mutation. -#### Inherited from %{#Properties-storeId-Inherited-from}% +#### Inherited from [_SubscriptionCallbackMutationBase](pinia._SubscriptionCallbackMutationBase.md).[storeId](pinia._SubscriptionCallbackMutationBase.md#storeid) ___ -### type %{#Properties-type}% +### type • **type**: [`patchObject`](../enums/pinia.MutationType.md#patchobject) Type of the mutation. -#### Overrides %{#Properties-type-Overrides}% +#### Overrides [_SubscriptionCallbackMutationBase](pinia._SubscriptionCallbackMutationBase.md).[type](pinia._SubscriptionCallbackMutationBase.md#type) diff --git a/packages/docs/api/interfaces/pinia._StoreOnActionListenerContext.md b/packages/docs/api/interfaces/pinia._StoreOnActionListenerContext.md index 47bfa53c..6e235ae2 100644 --- a/packages/docs/api/interfaces/pinia._StoreOnActionListenerContext.md +++ b/packages/docs/api/interfaces/pinia._StoreOnActionListenerContext.md @@ -12,7 +12,7 @@ Actual type for [StoreOnActionListenerContext](../modules/pinia.md#storeonaction purposes. For internal use only. For internal use **only** -## Type parameters %{#Type-parameters}% +## Type parameters | Name | Type | | :------ | :------ | @@ -20,32 +20,32 @@ For internal use **only** | `ActionName` | extends `string` | | `A` | `A` | -## Properties %{#Properties}% +## Properties -### after %{#Properties-after}% +### after • **after**: (`callback`: `A` extends `Record`<`ActionName`, [`_Method`](../modules/pinia.md#_method)\> ? (`resolvedReturn`: [`_Awaited`](../modules/pinia.md#_awaited)<`ReturnType`<`A`[`ActionName`]\>\>) => `void` : () => `void`) => `void` -#### Type declaration %{#Properties-after-Type-declaration}% +#### Type declaration ▸ (`callback`): `void` 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 %{#Properties-after-Type-declaration-Parameters}% +##### Parameters | Name | Type | | :------ | :------ | | `callback` | `A` extends `Record`<`ActionName`, [`_Method`](../modules/pinia.md#_method)\> ? (`resolvedReturn`: [`_Awaited`](../modules/pinia.md#_awaited)<`ReturnType`<`A`[`ActionName`]\>\>) => `void` : () => `void` | -##### Returns %{#Properties-after-Type-declaration-Returns}% +##### Returns `void` ___ -### args %{#Properties-args}% +### args • **args**: `A` extends `Record`<`ActionName`, [`_Method`](../modules/pinia.md#_method)\> ? `Parameters`<`A`[`ActionName`]\> : `unknown`[] @@ -53,7 +53,7 @@ Parameters passed to the action ___ -### name %{#Properties-name}% +### name • **name**: `ActionName` @@ -61,30 +61,30 @@ Name of the action ___ -### onError %{#Properties-onError}% +### onError • **onError**: (`callback`: (`error`: `unknown`) => `void`) => `void` -#### Type declaration %{#Properties-onError-Type-declaration}% +#### Type declaration ▸ (`callback`): `void` Sets up a hook if the action fails. Return `false` to catch the error and stop it from propagating. -##### Parameters %{#Properties-onError-Type-declaration-Parameters}% +##### Parameters | Name | Type | | :------ | :------ | | `callback` | (`error`: `unknown`) => `void` | -##### Returns %{#Properties-onError-Type-declaration-Returns}% +##### Returns `void` ___ -### store %{#Properties-store}% +### store • **store**: `Store` diff --git a/packages/docs/api/interfaces/pinia._StoreWithState.md b/packages/docs/api/interfaces/pinia._StoreWithState.md index a1d1bccb..dfc83c87 100644 --- a/packages/docs/api/interfaces/pinia._StoreWithState.md +++ b/packages/docs/api/interfaces/pinia._StoreWithState.md @@ -10,7 +10,7 @@ editLink: false Base store with state and functions. Should not be used directly. -## Type parameters %{#Type-parameters}% +## Type parameters | Name | Type | | :------ | :------ | @@ -19,27 +19,27 @@ Base store with state and functions. Should not be used directly. | `G` | `G` | | `A` | `A` | -## Hierarchy %{#Hierarchy}% +## Hierarchy - [`StoreProperties`](pinia.StoreProperties.md)<`Id`\> ↳ **`_StoreWithState`** -## Properties %{#Properties}% +## Properties -### $id %{#Properties-$id}% +### $id • **$id**: `Id` Unique identifier of the store -#### Inherited from %{#Properties-$id-Inherited-from}% +#### Inherited from [StoreProperties](pinia.StoreProperties.md).[$id](pinia.StoreProperties.md#$id) ___ -### $state %{#Properties-$state}% +### $state • **$state**: `UnwrapRef`<`S`\> & [`PiniaCustomStateProperties`](pinia.PiniaCustomStateProperties.md)<`S`\> @@ -47,7 +47,7 @@ State of the Store. Setting it will internally call `$patch()` to update the sta ___ -### \_customProperties %{#Properties-_customProperties}% +### \_customProperties • **\_customProperties**: `Set`<`string`\> @@ -55,13 +55,13 @@ Used by devtools plugin to retrieve properties added with plugins. Removed in production. Can be used by the user to add property keys of the store that should be displayed in devtools. -#### Inherited from %{#Properties-_customProperties-Inherited-from}% +#### Inherited from [StoreProperties](pinia.StoreProperties.md).[_customProperties](pinia.StoreProperties.md#_customproperties) -## Methods %{#Methods}% +## Methods -### $dispose %{#Methods-$dispose}% +### $dispose ▸ **$dispose**(): `void` @@ -72,13 +72,13 @@ Note this doesn't delete the state of the store, you have to do it manually with `delete pinia.state.value[store.$id]` if you want to. If you don't and the store is used again, it will reuse the previous state. -#### Returns %{#Methods-$dispose-Returns}% +#### Returns `void` ___ -### $onAction %{#Methods-$onAction}% +### $onAction ▸ **$onAction**(`callback`, `detached?`): () => `void` @@ -96,31 +96,14 @@ 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`** - -```js -store.$onAction(({ after, onError }) => { - // Here you could share variables between all of the hooks as well as - // setting up watchers and clean them up - after((resolvedValue) => { - // can be used to cleanup side effects -. // `resolvedValue` is the value returned by the action, if it's a -. // Promise, it will be the resolved value instead of the Promise - }) - onError((error) => { - // can be used to pass up errors - }) -}) -``` - -#### Parameters %{#Methods-$onAction-Parameters}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `callback` | [`StoreOnActionListener`](../modules/pinia.md#storeonactionlistener)<`Id`, `S`, `G`, `A`\> | callback called before every action | | `detached?` | `boolean` | detach the subscription from the context this is called from | -#### Returns %{#Methods-$onAction-Returns}% +#### Returns `fn` @@ -142,6 +125,12 @@ 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. +##### Returns + +`void` + +function that removes the watcher + **`Example`** ```js @@ -159,27 +148,38 @@ store.$onAction(({ after, onError }) => { }) ``` -##### Returns %{#Methods-$onAction-Returns-Returns}% - -`void` +**`Example`** -function that removes the watcher +```js +store.$onAction(({ after, onError }) => { + // Here you could share variables between all of the hooks as well as + // setting up watchers and clean them up + after((resolvedValue) => { + // can be used to cleanup side effects +. // `resolvedValue` is the value returned by the action, if it's a +. // Promise, it will be the resolved value instead of the Promise + }) + onError((error) => { + // can be used to pass up errors + }) +}) +``` ___ -### $patch %{#Methods-$patch}% +### $patch ▸ **$patch**(`partialState`): `void` Applies a state patch to current state. Allows passing nested values -#### Parameters %{#Methods-$patch-Parameters}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `partialState` | [`_DeepPartial`](../modules/pinia.md#_deeppartial)<`UnwrapRef`<`S`\>\> | patch to apply to the state | -#### Returns %{#Methods-$patch-Returns}% +#### Returns `void` @@ -189,38 +189,38 @@ Group multiple changes into one function. Useful when mutating objects like Sets or arrays and applying an object patch isn't practical, e.g. appending to an array. The function passed to `$patch()` **must be synchronous**. -#### Type parameters %{#Methods-$patch-Type-parameters}% +#### Type parameters | Name | Type | | :------ | :------ | | `F` | extends (`state`: `UnwrapRef`<`S`\>) => `any` | -#### Parameters %{#Methods-$patch-Parameters_1}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `stateMutator` | `ReturnType`<`F`\> extends `Promise`<`any`\> ? `never` : `F` | function that mutates `state`, cannot be asynchronous | -#### Returns %{#Methods-$patch-Returns_1}% +#### Returns `void` ___ -### $reset %{#Methods-$reset}% +### $reset ▸ **$reset**(): `void` Resets the store to its initial state by building a new state object. TODO: make this options only -#### Returns %{#Methods-$reset-Returns}% +#### Returns `void` ___ -### $subscribe %{#Methods-$subscribe}% +### $subscribe ▸ **$subscribe**(`callback`, `options?`): () => `void` @@ -228,14 +228,14 @@ Setups a callback to be called whenever the state changes. It also returns a fun 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 %{#Methods-$subscribe-Parameters}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `callback` | [`SubscriptionCallback`](../modules/pinia.md#subscriptioncallback)<`S`\> | callback passed to the watcher | | `options?` | { `detached?`: `boolean` } & `WatchOptions`<`boolean`\> | `watch` options + `detached` to detach the subscription from the context (usually a component) this is called from. Note that the `flush` option does not affect calls to `store.$patch()`. | -#### Returns %{#Methods-$subscribe-Returns}% +#### Returns `fn` @@ -247,7 +247,7 @@ Setups a callback to be called whenever the state changes. It also returns a fun 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 %{#Methods-$subscribe-Returns-Returns}% +##### Returns `void` diff --git a/packages/docs/api/interfaces/pinia._SubscriptionCallbackMutationBase.md b/packages/docs/api/interfaces/pinia._SubscriptionCallbackMutationBase.md index b0cf4d64..e0166980 100644 --- a/packages/docs/api/interfaces/pinia._SubscriptionCallbackMutationBase.md +++ b/packages/docs/api/interfaces/pinia._SubscriptionCallbackMutationBase.md @@ -10,7 +10,7 @@ editLink: false Base type for the context passed to a subscription callback. Internal type. -## Hierarchy %{#Hierarchy}% +## Hierarchy - **`_SubscriptionCallbackMutationBase`** @@ -20,9 +20,9 @@ Base type for the context passed to a subscription callback. Internal type. ↳ [`SubscriptionCallbackMutationPatchObject`](pinia.SubscriptionCallbackMutationPatchObject.md) -## Properties %{#Properties}% +## Properties -### events %{#Properties-events}% +### events • `Optional` **events**: `DebuggerEvent` \| `DebuggerEvent`[] @@ -32,7 +32,7 @@ devtools and plugins **during development only**. ___ -### storeId %{#Properties-storeId}% +### storeId • **storeId**: `string` @@ -40,7 +40,7 @@ ___ ___ -### type %{#Properties-type}% +### type • **type**: [`MutationType`](../enums/pinia.MutationType.md) diff --git a/packages/docs/api/interfaces/pinia_nuxt.ModuleOptions.md b/packages/docs/api/interfaces/pinia_nuxt.ModuleOptions.md index fe3e64e7..0f61b493 100644 --- a/packages/docs/api/interfaces/pinia_nuxt.ModuleOptions.md +++ b/packages/docs/api/interfaces/pinia_nuxt.ModuleOptions.md @@ -8,34 +8,29 @@ editLink: false [@pinia/nuxt](../modules/pinia_nuxt.md).ModuleOptions -## Properties %{#Properties}% +## Properties -### autoImports %{#Properties-autoImports}% +### disableVuex -• `Optional` **autoImports**: (`string` \| [`string`, `string`])[] +• `Optional` **disableVuex**: `boolean` -Array of auto imports to be added to the nuxt.config.js file. +Pinia disables Vuex by default, set this option to `false` to avoid it and +use Pinia alongside Vuex (Nuxt 2 only) -**`Example`** +**`Default`** -```js -autoImports: [ - // automatically import `defineStore` - 'defineStore', - // automatically import `defineStore` as `definePiniaStore` - ['defineStore', 'definePiniaStore', -] -``` +`true` ___ -### disableVuex %{#Properties-disableVuex}% +### storesDirs -• `Optional` **disableVuex**: `boolean` +• `Optional` **storesDirs**: `string`[] -Pinia disables Vuex by default, set this option to `false` to avoid it and -use Pinia alongside Vuex (Nuxt 2 only) +Automatically add stores dirs to the auto imports. This is the same as +directly adding the dirs to the `imports.dirs` option. If you want to +also import nested stores, you can use the glob pattern `./stores/**` **`Default`** -`true` +`['./stores']` diff --git a/packages/docs/api/interfaces/pinia_testing.TestingOptions.md b/packages/docs/api/interfaces/pinia_testing.TestingOptions.md index ff56160a..1af6d912 100644 --- a/packages/docs/api/interfaces/pinia_testing.TestingOptions.md +++ b/packages/docs/api/interfaces/pinia_testing.TestingOptions.md @@ -8,13 +8,13 @@ editLink: false [@pinia/testing](../modules/pinia_testing.md).TestingOptions -## Properties %{#Properties}% +## Properties -### createSpy %{#Properties-createSpy}% +### createSpy • `Optional` **createSpy**: (`fn?`: (...`args`: `any`[]) => `any`) => (...`args`: `any`[]) => `any` -#### Type declaration %{#Properties-createSpy-Type-declaration}% +#### Type declaration ▸ (`fn?`): (...`args`: `any`[]) => `any` @@ -22,31 +22,31 @@ Function used to create a spy for actions and `$patch()`. Pre-configured with `jest.fn` in Jest projects or `vi.fn` in Vitest projects if `globals: true` is set. -##### Parameters %{#Properties-createSpy-Type-declaration-Parameters}% +##### Parameters | Name | Type | | :------ | :------ | | `fn?` | (...`args`: `any`[]) => `any` | -##### Returns %{#Properties-createSpy-Type-declaration-Returns}% +##### Returns `fn` ▸ (`...args`): `any` -##### Parameters %{#Properties-createSpy-Type-declaration-Parameters_1}% +##### Parameters | Name | Type | | :------ | :------ | | `...args` | `any`[] | -##### Returns %{#Properties-createSpy-Type-declaration-Returns_1}% +##### Returns `any` ___ -### fakeApp %{#Properties-fakeApp}% +### fakeApp • `Optional` **fakeApp**: `boolean` @@ -57,7 +57,7 @@ Defaults to false. ___ -### initialState %{#Properties-initialState}% +### initialState • `Optional` **initialState**: [`StateTree`](../modules/pinia.md#statetree) @@ -66,7 +66,7 @@ allowing you to only set a few properties that are required in your test. ___ -### plugins %{#Properties-plugins}% +### plugins • `Optional` **plugins**: [`PiniaPlugin`](pinia.PiniaPlugin.md)[] @@ -75,7 +75,7 @@ your application that will be used while testing. ___ -### stubActions %{#Properties-stubActions}% +### stubActions • `Optional` **stubActions**: `boolean` @@ -87,7 +87,7 @@ handle this in `createSpy()`. ___ -### stubPatch %{#Properties-stubPatch}% +### stubPatch • `Optional` **stubPatch**: `boolean` @@ -97,7 +97,7 @@ argument `undefined`. You still have to handle this in `createSpy()`. ___ -### stubReset %{#Properties-stubReset}% +### stubReset • `Optional` **stubReset**: `boolean` diff --git a/packages/docs/api/interfaces/pinia_testing.TestingPinia.md b/packages/docs/api/interfaces/pinia_testing.TestingPinia.md index ae8ebe61..19403333 100644 --- a/packages/docs/api/interfaces/pinia_testing.TestingPinia.md +++ b/packages/docs/api/interfaces/pinia_testing.TestingPinia.md @@ -11,15 +11,15 @@ editLink: false Pinia instance specifically designed for testing. Extends a regular `Pinia` instance with test specific properties. -## Hierarchy %{#Hierarchy}% +## Hierarchy - [`Pinia`](pinia.Pinia.md) ↳ **`TestingPinia`** -## Properties %{#Properties}% +## Properties -### app %{#Properties-app}% +### app • **app**: `App`<`any`\> @@ -27,58 +27,58 @@ App used by Pinia ___ -### install %{#Properties-install}% +### install • **install**: (`app`: `App`<`any`\>) => `void` -#### Type declaration %{#Properties-install-Type-declaration}% +#### Type declaration ▸ (`app`): `void` -##### Parameters %{#Properties-install-Type-declaration-Parameters}% +##### Parameters | Name | Type | | :------ | :------ | | `app` | `App`<`any`\> | -##### Returns %{#Properties-install-Type-declaration-Returns}% +##### Returns `void` -#### Inherited from %{#Properties-install-Inherited-from}% +#### Inherited from [Pinia](pinia.Pinia.md).[install](pinia.Pinia.md#install) ___ -### state %{#Properties-state}% +### state • **state**: `Ref`<`Record`<`string`, [`StateTree`](../modules/pinia.md#statetree)\>\> root state -#### Inherited from %{#Properties-state-Inherited-from}% +#### Inherited from [Pinia](pinia.Pinia.md).[state](pinia.Pinia.md#state) -## Methods %{#Methods}% +## Methods -### use %{#Methods-use}% +### use ▸ **use**(`plugin`): [`Pinia`](pinia.Pinia.md) Adds a store plugin to extend every store -#### Parameters %{#Methods-use-Parameters}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `plugin` | [`PiniaPlugin`](pinia.PiniaPlugin.md) | store plugin to add | -#### Returns %{#Methods-use-Returns}% +#### Returns [`Pinia`](pinia.Pinia.md) -#### Inherited from %{#Methods-use-Inherited-from}% +#### Inherited from [Pinia](pinia.Pinia.md).[use](pinia.Pinia.md#use) diff --git a/packages/docs/api/modules/pinia.md b/packages/docs/api/modules/pinia.md index ea5dbbb9..d12dba89 100644 --- a/packages/docs/api/modules/pinia.md +++ b/packages/docs/api/modules/pinia.md @@ -6,11 +6,11 @@ editLink: false # Module: pinia -## Enumerations %{#Enumerations}% +## Enumerations - [MutationType](../enums/pinia.MutationType.md) -## Interfaces %{#Interfaces}% +## Interfaces - [DefineSetupStoreOptions](../interfaces/pinia.DefineSetupStoreOptions.md) - [DefineStoreOptions](../interfaces/pinia.DefineStoreOptions.md) @@ -31,9 +31,9 @@ editLink: false - [\_StoreWithState](../interfaces/pinia._StoreWithState.md) - [\_SubscriptionCallbackMutationBase](../interfaces/pinia._SubscriptionCallbackMutationBase.md) -## Type Aliases %{#Type-Aliases}% +## Type Aliases -### PiniaStorePlugin %{#Type-Aliases-PiniaStorePlugin}% +### PiniaStorePlugin Ƭ **PiniaStorePlugin**: [`PiniaPlugin`](../interfaces/pinia.PiniaPlugin.md) @@ -45,7 +45,7 @@ use PiniaPlugin instead ___ -### StateTree %{#Type-Aliases-StateTree}% +### StateTree Ƭ **StateTree**: `Record`<`string` \| `number` \| `symbol`, `any`\> @@ -53,13 +53,13 @@ Generic state of a Store ___ -### Store %{#Type-Aliases-Store}% +### 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`](../interfaces/pinia.PiniaCustomStateProperties.md)<`S`\> Store type to build a store. -#### Type parameters %{#Type-Aliases-Store-Type-parameters}% +#### Type parameters | Name | Type | | :------ | :------ | @@ -70,14 +70,14 @@ Store type to build a store. ___ -### StoreActions %{#Type-Aliases-StoreActions}% +### StoreActions Ƭ **StoreActions**<`SS`\>: `SS` extends [`Store`](pinia.md#store)<`string`, [`StateTree`](pinia.md#statetree), [`_GettersTree`](pinia.md#_getterstree)<[`StateTree`](pinia.md#statetree)\>, infer A\> ? `A` : [`_ExtractActionsFromSetupStore`](pinia.md#_extractactionsfromsetupstore)<`SS`\> Extract the actions of a store type. Works with both a Setup Store or an Options Store. -#### Type parameters %{#Type-Aliases-StoreActions-Type-parameters}% +#### Type parameters | Name | | :------ | @@ -85,7 +85,7 @@ Options Store. ___ -### StoreGeneric %{#Type-Aliases-StoreGeneric}% +### StoreGeneric Ƭ **StoreGeneric**: [`Store`](pinia.md#store)<`string`, [`StateTree`](pinia.md#statetree), [`_GettersTree`](pinia.md#_getterstree)<[`StateTree`](pinia.md#statetree)\>, [`_ActionsTree`](pinia.md#_actionstree)\> @@ -95,14 +95,14 @@ about the kind of store that is passed. ___ -### StoreGetters %{#Type-Aliases-StoreGetters}% +### StoreGetters Ƭ **StoreGetters**<`SS`\>: `SS` extends [`Store`](pinia.md#store)<`string`, [`StateTree`](pinia.md#statetree), infer G, [`_ActionsTree`](pinia.md#_actionstree)\> ? [`_StoreWithGetters`](pinia.md#_storewithgetters)<`G`\> : [`_ExtractGettersFromSetupStore`](pinia.md#_extractgettersfromsetupstore)<`SS`\> Extract the getters of a store type. Works with both a Setup Store or an Options Store. -#### Type parameters %{#Type-Aliases-StoreGetters-Type-parameters}% +#### Type parameters | Name | | :------ | @@ -110,11 +110,11 @@ Options Store. ___ -### StoreOnActionListener %{#Type-Aliases-StoreOnActionListener}% +### StoreOnActionListener Ƭ **StoreOnActionListener**<`Id`, `S`, `G`, `A`\>: (`context`: [`StoreOnActionListenerContext`](pinia.md#storeonactionlistenercontext)<`Id`, `S`, `G`, {} extends `A` ? [`_ActionsTree`](pinia.md#_actionstree) : `A`\>) => `void` -#### Type parameters %{#Type-Aliases-StoreOnActionListener-Type-parameters}% +#### Type parameters | Name | Type | | :------ | :------ | @@ -123,32 +123,32 @@ ___ | `G` | `G` | | `A` | `A` | -#### Type declaration %{#Type-Aliases-StoreOnActionListener-Type-declaration}% +#### Type declaration ▸ (`context`): `void` Argument of `store.$onAction()` -##### Parameters %{#Type-Aliases-StoreOnActionListener-Type-declaration-Parameters}% +##### Parameters | Name | Type | | :------ | :------ | | `context` | [`StoreOnActionListenerContext`](pinia.md#storeonactionlistenercontext)<`Id`, `S`, `G`, {} extends `A` ? [`_ActionsTree`](pinia.md#_actionstree) : `A`\> | -##### Returns %{#Type-Aliases-StoreOnActionListener-Type-declaration-Returns}% +##### Returns `void` ___ -### StoreOnActionListenerContext %{#Type-Aliases-StoreOnActionListenerContext}% +### StoreOnActionListenerContext Ƭ **StoreOnActionListenerContext**<`Id`, `S`, `G`, `A`\>: [`_ActionsTree`](pinia.md#_actionstree) extends `A` ? [`_StoreOnActionListenerContext`](../interfaces/pinia._StoreOnActionListenerContext.md)<[`StoreGeneric`](pinia.md#storegeneric), `string`, [`_ActionsTree`](pinia.md#_actionstree)\> : { [Name in keyof A]: Name extends string ? \_StoreOnActionListenerContext, Name, A\> : never }[keyof `A`] Context object passed to callbacks of `store.$onAction(context => {})` TODO: should have only the Id, the Store and Actions to generate the proper object -#### Type parameters %{#Type-Aliases-StoreOnActionListenerContext-Type-parameters}% +#### Type parameters | Name | Type | | :------ | :------ | @@ -159,14 +159,14 @@ TODO: should have only the Id, the Store and Actions to generate the proper obje ___ -### StoreState %{#Type-Aliases-StoreState}% +### StoreState Ƭ **StoreState**<`SS`\>: `SS` extends [`Store`](pinia.md#store)<`string`, infer S, [`_GettersTree`](pinia.md#_getterstree)<[`StateTree`](pinia.md#statetree)\>, [`_ActionsTree`](pinia.md#_actionstree)\> ? `UnwrapRef`<`S`\> : [`_ExtractStateFromSetupStore`](pinia.md#_extractstatefromsetupstore)<`SS`\> Extract the state of a store type. Works with both a Setup Store or an Options Store. Note this unwraps refs. -#### Type parameters %{#Type-Aliases-StoreState-Type-parameters}% +#### Type parameters | Name | | :------ | @@ -174,42 +174,42 @@ Options Store. Note this unwraps refs. ___ -### SubscriptionCallback %{#Type-Aliases-SubscriptionCallback}% +### SubscriptionCallback Ƭ **SubscriptionCallback**<`S`\>: (`mutation`: [`SubscriptionCallbackMutation`](pinia.md#subscriptioncallbackmutation)<`S`\>, `state`: `UnwrapRef`<`S`\>) => `void` -#### Type parameters %{#Type-Aliases-SubscriptionCallback-Type-parameters}% +#### Type parameters | Name | | :------ | | `S` | -#### Type declaration %{#Type-Aliases-SubscriptionCallback-Type-declaration}% +#### Type declaration ▸ (`mutation`, `state`): `void` Callback of a subscription -##### Parameters %{#Type-Aliases-SubscriptionCallback-Type-declaration-Parameters}% +##### Parameters | Name | Type | | :------ | :------ | | `mutation` | [`SubscriptionCallbackMutation`](pinia.md#subscriptioncallbackmutation)<`S`\> | | `state` | `UnwrapRef`<`S`\> | -##### Returns %{#Type-Aliases-SubscriptionCallback-Type-declaration-Returns}% +##### Returns `void` ___ -### SubscriptionCallbackMutation %{#Type-Aliases-SubscriptionCallbackMutation}% +### SubscriptionCallbackMutation Ƭ **SubscriptionCallbackMutation**<`S`\>: [`SubscriptionCallbackMutationDirect`](../interfaces/pinia.SubscriptionCallbackMutationDirect.md) \| [`SubscriptionCallbackMutationPatchObject`](../interfaces/pinia.SubscriptionCallbackMutationPatchObject.md)<`S`\> \| [`SubscriptionCallbackMutationPatchFunction`](../interfaces/pinia.SubscriptionCallbackMutationPatchFunction.md) Context object passed to a subscription callback. -#### Type parameters %{#Type-Aliases-SubscriptionCallbackMutation-Type-parameters}% +#### Type parameters | Name | | :------ | @@ -217,7 +217,7 @@ Context object passed to a subscription callback. ___ -### \_ActionsTree %{#Type-Aliases-_ActionsTree}% +### \_ActionsTree Ƭ **\_ActionsTree**: `Record`<`string`, [`_Method`](pinia.md#_method)\> @@ -226,11 +226,11 @@ For internal use **only** ___ -### \_Awaited %{#Type-Aliases-_Awaited}% +### \_Awaited Ƭ **\_Awaited**<`T`\>: `T` extends ``null`` \| `undefined` ? `T` : `T` extends `object` & { `then`: (`onfulfilled`: `F`) => `any` } ? `F` extends (`value`: infer V, ...`args`: `any`) => `any` ? [`_Awaited`](pinia.md#_awaited)<`V`\> : `never` : `T` -#### Type parameters %{#Type-Aliases-_Awaited-Type-parameters}% +#### Type parameters | Name | | :------ | @@ -238,7 +238,7 @@ ___ ___ -### \_DeepPartial %{#Type-Aliases-_DeepPartial}% +### \_DeepPartial Ƭ **\_DeepPartial**<`T`\>: { [K in keyof T]?: \_DeepPartial } @@ -246,7 +246,7 @@ Recursive `Partial`. Used by [['$patch']](pinia.md#store). For internal use **only** -#### Type parameters %{#Type-Aliases-_DeepPartial-Type-parameters}% +#### Type parameters | Name | | :------ | @@ -254,13 +254,13 @@ For internal use **only** ___ -### \_ExtractActionsFromSetupStore %{#Type-Aliases-_ExtractActionsFromSetupStore}% +### \_ExtractActionsFromSetupStore Ƭ **\_ExtractActionsFromSetupStore**<`SS`\>: `SS` extends `undefined` \| `void` ? {} : [`_ExtractActionsFromSetupStore_Keys`](pinia.md#_extractactionsfromsetupstore_keys)<`SS`\> extends keyof `SS` ? `Pick`<`SS`, [`_ExtractActionsFromSetupStore_Keys`](pinia.md#_extractactionsfromsetupstore_keys)<`SS`\>\> : `never` For internal use **only** -#### Type parameters %{#Type-Aliases-_ExtractActionsFromSetupStore-Type-parameters}% +#### Type parameters | Name | | :------ | @@ -268,14 +268,14 @@ For internal use **only** ___ -### \_ExtractActionsFromSetupStore\_Keys %{#Type-Aliases-_ExtractActionsFromSetupStore_Keys}% +### \_ExtractActionsFromSetupStore\_Keys Ƭ **\_ExtractActionsFromSetupStore\_Keys**<`SS`\>: keyof { [K in keyof SS as SS[K] extends \_Method ? K : never]: any } Type that enables refactoring through IDE. For internal use **only** -#### Type parameters %{#Type-Aliases-_ExtractActionsFromSetupStore_Keys-Type-parameters}% +#### Type parameters | Name | | :------ | @@ -283,13 +283,13 @@ For internal use **only** ___ -### \_ExtractGettersFromSetupStore %{#Type-Aliases-_ExtractGettersFromSetupStore}% +### \_ExtractGettersFromSetupStore Ƭ **\_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** -#### Type parameters %{#Type-Aliases-_ExtractGettersFromSetupStore-Type-parameters}% +#### Type parameters | Name | | :------ | @@ -297,14 +297,14 @@ For internal use **only** ___ -### \_ExtractGettersFromSetupStore\_Keys %{#Type-Aliases-_ExtractGettersFromSetupStore_Keys}% +### \_ExtractGettersFromSetupStore\_Keys Ƭ **\_ExtractGettersFromSetupStore\_Keys**<`SS`\>: keyof { [K in keyof SS as SS[K] extends ComputedRef ? K : never]: any } Type that enables refactoring through IDE. For internal use **only** -#### Type parameters %{#Type-Aliases-_ExtractGettersFromSetupStore_Keys-Type-parameters}% +#### Type parameters | Name | | :------ | @@ -312,13 +312,13 @@ For internal use **only** ___ -### \_ExtractStateFromSetupStore %{#Type-Aliases-_ExtractStateFromSetupStore}% +### \_ExtractStateFromSetupStore Ƭ **\_ExtractStateFromSetupStore**<`SS`\>: `SS` extends `undefined` \| `void` ? {} : [`_ExtractStateFromSetupStore_Keys`](pinia.md#_extractstatefromsetupstore_keys)<`SS`\> extends keyof `SS` ? [`_UnwrapAll`](pinia.md#_unwrapall)<`Pick`<`SS`, [`_ExtractStateFromSetupStore_Keys`](pinia.md#_extractstatefromsetupstore_keys)<`SS`\>\>\> : `never` For internal use **only** -#### Type parameters %{#Type-Aliases-_ExtractStateFromSetupStore-Type-parameters}% +#### Type parameters | Name | | :------ | @@ -326,14 +326,14 @@ For internal use **only** ___ -### \_ExtractStateFromSetupStore\_Keys %{#Type-Aliases-_ExtractStateFromSetupStore_Keys}% +### \_ExtractStateFromSetupStore\_Keys Ƭ **\_ExtractStateFromSetupStore\_Keys**<`SS`\>: keyof { [K in keyof SS as SS[K] extends \_Method \| ComputedRef ? never : K]: any } Type that enables refactoring through IDE. For internal use **only** -#### Type parameters %{#Type-Aliases-_ExtractStateFromSetupStore_Keys-Type-parameters}% +#### Type parameters | Name | | :------ | @@ -341,14 +341,14 @@ For internal use **only** ___ -### \_GettersTree %{#Type-Aliases-_GettersTree}% +### \_GettersTree Ƭ **\_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** -#### Type parameters %{#Type-Aliases-_GettersTree-Type-parameters}% +#### Type parameters | Name | Type | | :------ | :------ | @@ -356,13 +356,13 @@ For internal use **only** ___ -### \_MapActionsObjectReturn %{#Type-Aliases-_MapActionsObjectReturn}% +### \_MapActionsObjectReturn Ƭ **\_MapActionsObjectReturn**<`A`, `T`\>: { [key in keyof T]: A[T[key]] } For internal use **only** -#### Type parameters %{#Type-Aliases-_MapActionsObjectReturn-Type-parameters}% +#### Type parameters | Name | Type | | :------ | :------ | @@ -371,13 +371,13 @@ For internal use **only** ___ -### \_MapActionsReturn %{#Type-Aliases-_MapActionsReturn}% +### \_MapActionsReturn Ƭ **\_MapActionsReturn**<`A`\>: { [key in keyof A]: A[key] } For internal use **only** -#### Type parameters %{#Type-Aliases-_MapActionsReturn-Type-parameters}% +#### Type parameters | Name | | :------ | @@ -385,13 +385,13 @@ For internal use **only** ___ -### \_MapStateObjectReturn %{#Type-Aliases-_MapStateObjectReturn}% +### \_MapStateObjectReturn Ƭ **\_MapStateObjectReturn**<`Id`, `S`, `G`, `A`, `T`\>: { [key in keyof T]: Function } For internal use **only** -#### Type parameters %{#Type-Aliases-_MapStateObjectReturn-Type-parameters}% +#### Type parameters | Name | Type | | :------ | :------ | @@ -403,13 +403,13 @@ For internal use **only** ___ -### \_MapStateReturn %{#Type-Aliases-_MapStateReturn}% +### \_MapStateReturn Ƭ **\_MapStateReturn**<`S`, `G`, `Keys`\>: { [key in Keys]: Function } For internal use **only** -#### Type parameters %{#Type-Aliases-_MapStateReturn-Type-parameters}% +#### Type parameters | Name | Type | | :------ | :------ | @@ -419,13 +419,13 @@ For internal use **only** ___ -### \_MapWritableStateObjectReturn %{#Type-Aliases-_MapWritableStateObjectReturn}% +### \_MapWritableStateObjectReturn Ƭ **\_MapWritableStateObjectReturn**<`S`, `T`\>: { [key in keyof T]: Object } For internal use **only** -#### Type parameters %{#Type-Aliases-_MapWritableStateObjectReturn-Type-parameters}% +#### Type parameters | Name | Type | | :------ | :------ | @@ -434,13 +434,13 @@ For internal use **only** ___ -### \_MapWritableStateReturn %{#Type-Aliases-_MapWritableStateReturn}% +### \_MapWritableStateReturn Ƭ **\_MapWritableStateReturn**<`S`\>: { [key in keyof S]: Object } For internal use **only** -#### Type parameters %{#Type-Aliases-_MapWritableStateReturn-Type-parameters}% +#### Type parameters | Name | Type | | :------ | :------ | @@ -448,11 +448,11 @@ For internal use **only** ___ -### \_Method %{#Type-Aliases-_Method}% +### \_Method Ƭ **\_Method**: (...`args`: `any`[]) => `any` -#### Type declaration %{#Type-Aliases-_Method-Type-declaration}% +#### Type declaration ▸ (`...args`): `any` @@ -460,25 +460,25 @@ Generic type for a function that can infer arguments and return type For internal use **only** -##### Parameters %{#Type-Aliases-_Method-Type-declaration-Parameters}% +##### Parameters | Name | Type | | :------ | :------ | | `...args` | `any`[] | -##### Returns %{#Type-Aliases-_Method-Type-declaration-Returns}% +##### Returns `any` ___ -### \_Spread %{#Type-Aliases-_Spread}% +### \_Spread Ƭ **\_Spread**<`A`\>: `A` extends [infer L, ...(infer R)] ? [`_StoreObject`](pinia.md#_storeobject)<`L`\> & [`_Spread`](pinia.md#_spread)<`R`\> : `unknown` For internal use **only**. -#### Type parameters %{#Type-Aliases-_Spread-Type-parameters}% +#### Type parameters | Name | Type | | :------ | :------ | @@ -486,13 +486,13 @@ For internal use **only**. ___ -### \_StoreObject %{#Type-Aliases-_StoreObject}% +### \_StoreObject Ƭ **\_StoreObject**<`S`\>: `S` extends [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md) ? { [Id in \`${Ids}${MapStoresCustomization extends Record<"suffix", infer Suffix\> ? Suffix : "Store"}\`]: Function } : {} For internal use **only**. -#### Type parameters %{#Type-Aliases-_StoreObject-Type-parameters}% +#### Type parameters | Name | | :------ | @@ -500,14 +500,14 @@ For internal use **only**. ___ -### \_StoreWithActions %{#Type-Aliases-_StoreWithActions}% +### \_StoreWithActions Ƭ **\_StoreWithActions**<`A`\>: { [k in keyof A]: A[k] extends Function ? Function : never } Store augmented for actions. For internal usage only. For internal use **only** -#### Type parameters %{#Type-Aliases-_StoreWithActions-Type-parameters}% +#### Type parameters | Name | | :------ | @@ -515,14 +515,14 @@ For internal use **only** ___ -### \_StoreWithGetters %{#Type-Aliases-_StoreWithGetters}% +### \_StoreWithGetters Ƭ **\_StoreWithGetters**<`G`\>: { readonly [k in keyof G]: G[k] extends Function ? R : UnwrapRef } Store augmented with getters. For internal usage only. For internal use **only** -#### Type parameters %{#Type-Aliases-_StoreWithGetters-Type-parameters}% +#### Type parameters | Name | | :------ | @@ -530,22 +530,22 @@ For internal use **only** ___ -### \_UnwrapAll %{#Type-Aliases-_UnwrapAll}% +### \_UnwrapAll Ƭ **\_UnwrapAll**<`SS`\>: { [K in keyof SS]: UnwrapRef } Type that enables refactoring through IDE. For internal use **only** -#### Type parameters %{#Type-Aliases-_UnwrapAll-Type-parameters}% +#### Type parameters | Name | | :------ | | `SS` | -## Variables %{#Variables}% +## Variables -### PiniaVuePlugin %{#Variables-PiniaVuePlugin}% +### PiniaVuePlugin • `Const` **PiniaVuePlugin**: `Plugin` @@ -573,24 +573,15 @@ new Vue({ `Vue` imported from 'vue'. -## Functions %{#Functions}% +## Functions -### acceptHMRUpdate %{#Functions-acceptHMRUpdate}% +### acceptHMRUpdate ▸ **acceptHMRUpdate**<`Id`, `S`, `G`, `A`\>(`initialUseStore`, `hot`): (`newModule`: `any`) => `any` Creates an _accept_ function to pass to `import.meta.hot` in Vite applications. -**`Example`** - -```js -const useUser = defineStore(...) -if (import.meta.hot) { - import.meta.hot.accept(acceptHMRUpdate(useUser, import.meta.hot)) -} -``` - -#### Type parameters %{#Functions-acceptHMRUpdate-Type-parameters}% +#### Type parameters | Name | Type | | :------ | :------ | @@ -599,50 +590,59 @@ if (import.meta.hot) { | `G` | extends [`_GettersTree`](pinia.md#_getterstree)<`S`\> = [`_GettersTree`](pinia.md#_getterstree)<`S`\> | | `A` | [`_ActionsTree`](pinia.md#_actionstree) | -#### Parameters %{#Functions-acceptHMRUpdate-Parameters}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `initialUseStore` | [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)<`Id`, `S`, `G`, `A`\> | return of the defineStore to hot update | | `hot` | `any` | `import.meta.hot` | -#### Returns %{#Functions-acceptHMRUpdate-Returns}% +#### Returns `fn` ▸ (`newModule`): `any` -##### Parameters %{#Functions-acceptHMRUpdate-Returns-Parameters}% +##### Parameters | Name | Type | | :------ | :------ | | `newModule` | `any` | -##### Returns %{#Functions-acceptHMRUpdate-Returns-Returns}% +##### Returns `any` +**`Example`** + +```js +const useUser = defineStore(...) +if (import.meta.hot) { + import.meta.hot.accept(acceptHMRUpdate(useUser, import.meta.hot)) +} +``` + ___ -### createPinia %{#Functions-createPinia}% +### createPinia ▸ **createPinia**(): [`Pinia`](../interfaces/pinia.Pinia.md) Creates a Pinia instance to be used by the application -#### Returns %{#Functions-createPinia-Returns}% +#### Returns [`Pinia`](../interfaces/pinia.Pinia.md) ___ -### defineStore %{#Functions-defineStore}% +### defineStore ▸ **defineStore**<`Id`, `S`, `G`, `A`\>(`id`, `options`): [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)<`Id`, `S`, `G`, `A`\> Creates a `useStore` function that retrieves the store instance -#### Type parameters %{#Functions-defineStore-Type-parameters}% +#### Type parameters | Name | Type | | :------ | :------ | @@ -651,14 +651,14 @@ Creates a `useStore` function that retrieves the store instance | `G` | extends [`_GettersTree`](pinia.md#_getterstree)<`S`\> = {} | | `A` | {} | -#### Parameters %{#Functions-defineStore-Parameters}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `id` | `Id` | id of the store (must be unique) | | `options` | `Omit`<[`DefineStoreOptions`](../interfaces/pinia.DefineStoreOptions.md)<`Id`, `S`, `G`, `A`\>, ``"id"``\> | options to define the store | -#### Returns %{#Functions-defineStore-Returns}% +#### Returns [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)<`Id`, `S`, `G`, `A`\> @@ -666,7 +666,7 @@ Creates a `useStore` function that retrieves the store instance Creates a `useStore` function that retrieves the store instance -#### Type parameters %{#Functions-defineStore-Type-parameters_1}% +#### Type parameters | Name | Type | | :------ | :------ | @@ -675,13 +675,13 @@ Creates a `useStore` function that retrieves the store instance | `G` | extends [`_GettersTree`](pinia.md#_getterstree)<`S`\> = {} | | `A` | {} | -#### Parameters %{#Functions-defineStore-Parameters_1}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `options` | [`DefineStoreOptions`](../interfaces/pinia.DefineStoreOptions.md)<`Id`, `S`, `G`, `A`\> | options to define the store | -#### Returns %{#Functions-defineStore-Returns_1}% +#### Returns [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)<`Id`, `S`, `G`, `A`\> @@ -689,14 +689,14 @@ Creates a `useStore` function that retrieves the store instance Creates a `useStore` function that retrieves the store instance -#### Type parameters %{#Functions-defineStore-Type-parameters_2}% +#### Type parameters | Name | Type | | :------ | :------ | | `Id` | extends `string` | | `SS` | `SS` | -#### Parameters %{#Functions-defineStore-Parameters_2}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | @@ -704,25 +704,25 @@ Creates a `useStore` function that retrieves the store instance | `storeSetup` | () => `SS` | function that defines the store | | `options?` | [`DefineSetupStoreOptions`](../interfaces/pinia.DefineSetupStoreOptions.md)<`Id`, [`_ExtractStateFromSetupStore`](pinia.md#_extractstatefromsetupstore)<`SS`\>, [`_ExtractGettersFromSetupStore`](pinia.md#_extractgettersfromsetupstore)<`SS`\>, [`_ExtractActionsFromSetupStore`](pinia.md#_extractactionsfromsetupstore)<`SS`\>\> | extra options | -#### Returns %{#Functions-defineStore-Returns_2}% +#### Returns [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)<`Id`, [`_ExtractStateFromSetupStore`](pinia.md#_extractstatefromsetupstore)<`SS`\>, [`_ExtractGettersFromSetupStore`](pinia.md#_extractgettersfromsetupstore)<`SS`\>, [`_ExtractActionsFromSetupStore`](pinia.md#_extractactionsfromsetupstore)<`SS`\>\> ___ -### getActivePinia %{#Functions-getActivePinia}% +### getActivePinia ▸ **getActivePinia**(): `undefined` \| [`Pinia`](../interfaces/pinia.Pinia.md) Get the currently active pinia if there is any. -#### Returns %{#Functions-getActivePinia-Returns}% +#### Returns `undefined` \| [`Pinia`](../interfaces/pinia.Pinia.md) ___ -### mapActions %{#Functions-mapActions}% +### mapActions ▸ **mapActions**<`Id`, `S`, `G`, `A`, `KeyMapper`\>(`useStore`, `keyMapper`): [`_MapActionsObjectReturn`](pinia.md#_mapactionsobjectreturn)<`A`, `KeyMapper`\> @@ -731,24 +731,7 @@ 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`** - -```js -export default { - methods: { - // other methods properties - // useCounterStore has two actions named `increment` and `setCount` - ...mapActions(useCounterStore, { moar: 'increment', setIt: 'setCount' }) - }, - - created() { - this.moar() - this.setIt(2) - } -} -``` - -#### Type parameters %{#Functions-mapActions-Type-parameters}% +#### Type parameters | Name | Type | | :------ | :------ | @@ -758,40 +741,41 @@ export default { | `A` | `A` | | `KeyMapper` | extends `Record`<`string`, keyof `A`\> | -#### Parameters %{#Functions-mapActions-Parameters}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `useStore` | [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)<`Id`, `S`, `G`, `A`\> | store to map from | | `keyMapper` | `KeyMapper` | object to define new names for the actions | -#### Returns %{#Functions-mapActions-Returns}% +#### Returns [`_MapActionsObjectReturn`](pinia.md#_mapactionsobjectreturn)<`A`, `KeyMapper`\> -▸ **mapActions**<`Id`, `S`, `G`, `A`\>(`useStore`, `keys`): [`_MapActionsReturn`](pinia.md#_mapactionsreturn)<`A`\> - -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`** ```js export default { methods: { // other methods properties - ...mapActions(useCounterStore, ['increment', 'setCount']) + // useCounterStore has two actions named `increment` and `setCount` + ...mapActions(useCounterStore, { moar: 'increment', setIt: 'setCount' }) }, created() { - this.increment() - this.setCount(2) // pass arguments as usual + this.moar() + this.setIt(2) } } ``` -#### Type parameters %{#Functions-mapActions-Type-parameters_1}% +▸ **mapActions**<`Id`, `S`, `G`, `A`\>(`useStore`, `keys`): [`_MapActionsReturn`](pinia.md#_mapactionsreturn)<`A`\> + +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. + +#### Type parameters | Name | Type | | :------ | :------ | @@ -800,30 +784,42 @@ export default { | `G` | extends [`_GettersTree`](pinia.md#_getterstree)<`S`\> | | `A` | `A` | -#### Parameters %{#Functions-mapActions-Parameters_1}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `useStore` | [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)<`Id`, `S`, `G`, `A`\> | store to map from | | `keys` | keyof `A`[] | array of action names to map | -#### Returns %{#Functions-mapActions-Returns_1}% +#### Returns [`_MapActionsReturn`](pinia.md#_mapactionsreturn)<`A`\> +**`Example`** + +```js +export default { + methods: { + // other methods properties + ...mapActions(useCounterStore, ['increment', 'setCount']) + }, + + created() { + this.increment() + this.setCount(2) // pass arguments as usual + } +} +``` + ___ -### mapGetters %{#Functions-mapGetters}% +### mapGetters ▸ **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. -**`Deprecated`** - -use `mapState()` instead. - -#### Type parameters %{#Functions-mapGetters-Type-parameters}% +#### Type parameters | Name | Type | | :------ | :------ | @@ -833,26 +829,26 @@ use `mapState()` instead. | `A` | `A` | | `KeyMapper` | extends `Record`<`string`, keyof `S` \| keyof `G` \| (`store`: [`Store`](pinia.md#store)<`Id`, `S`, `G`, `A`\>) => `any`\> | -#### Parameters %{#Functions-mapGetters-Parameters}% +#### Parameters | Name | Type | | :------ | :------ | | `useStore` | [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)<`Id`, `S`, `G`, `A`\> | | `keyMapper` | `KeyMapper` | -#### Returns %{#Functions-mapGetters-Returns}% +#### Returns [`_MapStateObjectReturn`](pinia.md#_mapstateobjectreturn)<`Id`, `S`, `G`, `A`, `KeyMapper`\> -▸ **mapGetters**<`Id`, `S`, `G`, `A`, `Keys`\>(`useStore`, `keys`): [`_MapStateReturn`](pinia.md#_mapstatereturn)<`S`, `G`, `Keys`\> - -Alias for `mapState()`. You should use `mapState()` instead. - **`Deprecated`** use `mapState()` instead. -#### Type parameters %{#Functions-mapGetters-Type-parameters_1}% +▸ **mapGetters**<`Id`, `S`, `G`, `A`, `Keys`\>(`useStore`, `keys`): [`_MapStateReturn`](pinia.md#_mapstatereturn)<`S`, `G`, `Keys`\> + +Alias for `mapState()`. You should use `mapState()` instead. + +#### Type parameters | Name | Type | | :------ | :------ | @@ -862,20 +858,24 @@ use `mapState()` instead. | `A` | `A` | | `Keys` | extends `string` \| `number` \| `symbol` | -#### Parameters %{#Functions-mapGetters-Parameters_1}% +#### Parameters | Name | Type | | :------ | :------ | | `useStore` | [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)<`Id`, `S`, `G`, `A`\> | | `keys` | readonly `Keys`[] | -#### Returns %{#Functions-mapGetters-Returns_1}% +#### Returns [`_MapStateReturn`](pinia.md#_mapstatereturn)<`S`, `G`, `Keys`\> +**`Deprecated`** + +use `mapState()` instead. + ___ -### mapState %{#Functions-mapState}% +### mapState ▸ **mapState**<`Id`, `S`, `G`, `A`, `KeyMapper`\>(`useStore`, `keyMapper`): [`_MapStateObjectReturn`](pinia.md#_mapstateobjectreturn)<`Id`, `S`, `G`, `A`, `KeyMapper`\> @@ -887,6 +887,27 @@ 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. +#### Type parameters + +| Name | Type | +| :------ | :------ | +| `Id` | extends `string` | +| `S` | extends [`StateTree`](pinia.md#statetree) | +| `G` | extends [`_GettersTree`](pinia.md#_getterstree)<`S`\> | +| `A` | `A` | +| `KeyMapper` | extends `Record`<`string`, keyof `S` \| keyof `G` \| (`store`: [`Store`](pinia.md#store)<`Id`, `S`, `G`, `A`\>) => `any`\> | + +#### Parameters + +| 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 + +[`_MapStateObjectReturn`](pinia.md#_mapstateobjectreturn)<`Id`, `S`, `G`, `A`, `KeyMapper`\> + **`Example`** ```js @@ -912,7 +933,13 @@ export default { } ``` -#### Type parameters %{#Functions-mapState-Type-parameters}% +▸ **mapState**<`Id`, `S`, `G`, `A`, `Keys`\>(`useStore`, `keys`): [`_MapStateReturn`](pinia.md#_mapstatereturn)<`S`, `G`, `Keys`\> + +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. + +#### Type parameters | Name | Type | | :------ | :------ | @@ -920,24 +947,18 @@ export default { | `S` | extends [`StateTree`](pinia.md#statetree) | | `G` | extends [`_GettersTree`](pinia.md#_getterstree)<`S`\> | | `A` | `A` | -| `KeyMapper` | extends `Record`<`string`, keyof `S` \| keyof `G` \| (`store`: [`Store`](pinia.md#store)<`Id`, `S`, `G`, `A`\>) => `any`\> | +| `Keys` | extends `string` \| `number` \| `symbol` | -#### Parameters %{#Functions-mapState-Parameters}% +#### Parameters | 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 %{#Functions-mapState-Returns}% - -[`_MapStateObjectReturn`](pinia.md#_mapstateobjectreturn)<`Id`, `S`, `G`, `A`, `KeyMapper`\> +| `keys` | readonly `Keys`[] | array of state properties or getters | -▸ **mapState**<`Id`, `S`, `G`, `A`, `Keys`\>(`useStore`, `keys`): [`_MapStateReturn`](pinia.md#_mapstatereturn)<`S`, `G`, `Keys`\> +#### Returns -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. +[`_MapStateReturn`](pinia.md#_mapstatereturn)<`S`, `G`, `Keys`\> **`Example`** @@ -955,36 +976,31 @@ export default { } ``` -#### Type parameters %{#Functions-mapState-Type-parameters_1}% +___ + +### mapStores + +▸ **mapStores**<`Stores`\>(`...stores`): [`_Spread`](pinia.md#_spread)<`Stores`\> + +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. + +#### Type parameters | Name | Type | | :------ | :------ | -| `Id` | extends `string` | -| `S` | extends [`StateTree`](pinia.md#statetree) | -| `G` | extends [`_GettersTree`](pinia.md#_getterstree)<`S`\> | -| `A` | `A` | -| `Keys` | extends `string` \| `number` \| `symbol` | +| `Stores` | extends `any`[] | -#### Parameters %{#Functions-mapState-Parameters_1}% +#### Parameters | 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 %{#Functions-mapState-Returns_1}% - -[`_MapStateReturn`](pinia.md#_mapstatereturn)<`S`, `G`, `Keys`\> - -___ - -### mapStores %{#Functions-mapStores}% +| `...stores` | [...Stores[]] | list of stores to map to an object | -▸ **mapStores**<`Stores`\>(`...stores`): [`_Spread`](pinia.md#_spread)<`Stores`\> +#### Returns -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. +[`_Spread`](pinia.md#_spread)<`Stores`\> **`Example`** @@ -1002,25 +1018,9 @@ export default { } ``` -#### Type parameters %{#Functions-mapStores-Type-parameters}% - -| Name | Type | -| :------ | :------ | -| `Stores` | extends `any`[] | - -#### Parameters %{#Functions-mapStores-Parameters}% - -| Name | Type | Description | -| :------ | :------ | :------ | -| `...stores` | [...Stores[]] | list of stores to map to an object | - -#### Returns %{#Functions-mapStores-Returns}% - -[`_Spread`](pinia.md#_spread)<`Stores`\> - ___ -### mapWritableState %{#Functions-mapWritableState}% +### mapWritableState ▸ **mapWritableState**<`Id`, `S`, `G`, `A`, `KeyMapper`\>(`useStore`, `keyMapper`): [`_MapWritableStateObjectReturn`](pinia.md#_mapwritablestateobjectreturn)<`S`, `KeyMapper`\> @@ -1028,7 +1028,7 @@ Same as `mapState()` but creates computed setters as well so the state can be modified. Differently from `mapState()`, only `state` properties can be added. -#### Type parameters %{#Functions-mapWritableState-Type-parameters}% +#### Type parameters | Name | Type | | :------ | :------ | @@ -1038,14 +1038,14 @@ added. | `A` | `A` | | `KeyMapper` | extends `Record`<`string`, keyof `S`\> | -#### Parameters %{#Functions-mapWritableState-Parameters}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `useStore` | [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)<`Id`, `S`, `G`, `A`\> | store to map from | | `keyMapper` | `KeyMapper` | object of state properties | -#### Returns %{#Functions-mapWritableState-Returns}% +#### Returns [`_MapWritableStateObjectReturn`](pinia.md#_mapwritablestateobjectreturn)<`S`, `KeyMapper`\> @@ -1055,7 +1055,7 @@ 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. -#### Type parameters %{#Functions-mapWritableState-Type-parameters_1}% +#### Type parameters | Name | Type | | :------ | :------ | @@ -1065,33 +1065,33 @@ of a component. | `A` | `A` | | `Keys` | extends `string` \| `number` \| `symbol` | -#### Parameters %{#Functions-mapWritableState-Parameters_1}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `useStore` | [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)<`Id`, `S`, `G`, `A`\> | store to map from | | `keys` | readonly `Keys`[] | array of state properties | -#### Returns %{#Functions-mapWritableState-Returns_1}% +#### Returns { [K in Keys]: Object } ___ -### setActivePinia %{#Functions-setActivePinia}% +### setActivePinia ▸ **setActivePinia**(`pinia`): [`Pinia`](../interfaces/pinia.Pinia.md) Sets or unsets the active pinia. Used in SSR and internally when calling actions and getters -#### Parameters %{#Functions-setActivePinia-Parameters}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `pinia` | [`Pinia`](../interfaces/pinia.Pinia.md) | Pinia instance | -#### Returns %{#Functions-setActivePinia-Returns}% +#### Returns [`Pinia`](../interfaces/pinia.Pinia.md) @@ -1100,13 +1100,13 @@ actions and getters Sets or unsets the active pinia. Used in SSR and internally when calling actions and getters -#### Parameters %{#Functions-setActivePinia-Parameters_1}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `pinia` | `undefined` | Pinia instance | -#### Returns %{#Functions-setActivePinia-Returns_1}% +#### Returns `undefined` @@ -1115,19 +1115,19 @@ actions and getters Sets or unsets the active pinia. Used in SSR and internally when calling actions and getters -#### Parameters %{#Functions-setActivePinia-Parameters_2}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `pinia` | `undefined` \| [`Pinia`](../interfaces/pinia.Pinia.md) | Pinia instance | -#### Returns %{#Functions-setActivePinia-Returns_2}% +#### Returns `undefined` \| [`Pinia`](../interfaces/pinia.Pinia.md) ___ -### setMapStoreSuffix %{#Functions-setMapStoreSuffix}% +### setMapStoreSuffix ▸ **setMapStoreSuffix**(`suffix`): `void` @@ -1135,38 +1135,38 @@ 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 are using TypeScript. -#### Parameters %{#Functions-setMapStoreSuffix-Parameters}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `suffix` | `string` | new suffix | -#### Returns %{#Functions-setMapStoreSuffix-Returns}% +#### Returns `void` ___ -### skipHydrate %{#Functions-skipHydrate}% +### skipHydrate ▸ **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 %{#Functions-skipHydrate-Type-parameters}% +#### Type parameters | Name | Type | | :------ | :------ | | `T` | `any` | -#### Parameters %{#Functions-skipHydrate-Parameters}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `obj` | `T` | target object | -#### Returns %{#Functions-skipHydrate-Returns}% +#### Returns `T` @@ -1174,7 +1174,7 @@ obj ___ -### storeToRefs %{#Functions-storeToRefs}% +### storeToRefs ▸ **storeToRefs**<`SS`\>(`store`): `StoreToRefs`<`SS`\> @@ -1183,18 +1183,18 @@ state properties of the store. Similar to `toRefs()` but specifically designed for Pinia stores so methods and non reactive properties are completely ignored. -#### Type parameters %{#Functions-storeToRefs-Type-parameters}% +#### Type parameters | 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`\> & [`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 %{#Functions-storeToRefs-Parameters}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `store` | `SS` | store to extract the refs from | -#### Returns %{#Functions-storeToRefs-Returns}% +#### Returns `StoreToRefs`<`SS`\> diff --git a/packages/docs/api/modules/pinia_nuxt.md b/packages/docs/api/modules/pinia_nuxt.md index 4f301c09..8d325af3 100644 --- a/packages/docs/api/modules/pinia_nuxt.md +++ b/packages/docs/api/modules/pinia_nuxt.md @@ -6,17 +6,17 @@ editLink: false # Module: @pinia/nuxt -## Interfaces %{#Interfaces}% +## Interfaces - [ModuleOptions](../interfaces/pinia_nuxt.ModuleOptions.md) -## Functions %{#Functions}% +## Functions -### default %{#Functions-default}% +### default ▸ **default**(`this`, `inlineOptions`, `nuxt`): `_ModuleSetupReturn` -#### Parameters %{#Functions-default-Parameters}% +#### Parameters | Name | Type | | :------ | :------ | @@ -24,6 +24,6 @@ editLink: false | `inlineOptions` | [`ModuleOptions`](../interfaces/pinia_nuxt.ModuleOptions.md) | | `nuxt` | `Nuxt` | -#### Returns %{#Functions-default-Returns}% +#### Returns `_ModuleSetupReturn` diff --git a/packages/docs/api/modules/pinia_testing.md b/packages/docs/api/modules/pinia_testing.md index 94adb3bc..6b0ba1bd 100644 --- a/packages/docs/api/modules/pinia_testing.md +++ b/packages/docs/api/modules/pinia_testing.md @@ -6,14 +6,14 @@ editLink: false # Module: @pinia/testing -## Interfaces %{#Interfaces}% +## Interfaces - [TestingOptions](../interfaces/pinia_testing.TestingOptions.md) - [TestingPinia](../interfaces/pinia_testing.TestingPinia.md) -## Functions %{#Functions}% +## Functions -### createTestingPinia %{#Functions-createTestingPinia}% +### createTestingPinia ▸ **createTestingPinia**(`options?`): [`TestingPinia`](../interfaces/pinia_testing.TestingPinia.md) @@ -24,13 +24,13 @@ You can change this with the `stubActions` option. If you are using jest, they are replaced with `jest.fn()`, otherwise, you must provide your own `createSpy` option. -#### Parameters %{#Functions-createTestingPinia-Parameters}% +#### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `options` | [`TestingOptions`](../interfaces/pinia_testing.TestingOptions.md) | options to configure the testing pinia | -#### Returns %{#Functions-createTestingPinia-Returns}% +#### Returns [`TestingPinia`](../interfaces/pinia_testing.TestingPinia.md)