]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
docs: updates
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 5 Feb 2024 10:09:24 +0000 (11:09 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 5 Feb 2024 10:09:24 +0000 (11:09 +0100)
packages/docs/api/interfaces/pinia.DefineStoreOptions.md
packages/docs/api/interfaces/pinia.DefineStoreOptionsInPlugin.md
packages/docs/api/interfaces/pinia._StoreOnActionListenerContext.md
packages/docs/api/interfaces/pinia._StoreWithState.md
packages/docs/api/interfaces/pinia_testing.TestingOptions.md
packages/docs/api/modules/pinia.md

index 5a49133197d07d274c4fc2530fd14495ca0685cc..8c769ec1a8e65667b74974328b837b08c9ec90de 100644 (file)
@@ -60,6 +60,9 @@ ___
 
 • `Optional` **state**: () => `S`
 
+Function to create a fresh state. **Must be an arrow function** to ensure
+correct typings!
+
 #### Type declaration
 
 ▸ (): `S`
index bbc20a8b8918ad2bbc8d66565d27a3eaac8aea53..c5634ecd4347d99ab497b814a10d4c0b831c5ca5 100644 (file)
@@ -53,6 +53,9 @@ ___
 
 • `Optional` **state**: () => `S`
 
+Function to create a fresh state. **Must be an arrow function** to ensure
+correct typings!
+
 #### Type declaration
 
 ▸ (): `S`
index 4bdbf9f03992c0552393b4bfaaad89cc0c2a17e4..abd1608e8eade2b457b802205de46968b059aec4 100644 (file)
@@ -26,6 +26,9 @@ For internal use **only**
 
 • **after**: (`callback`: `A` extends `Record`\<`ActionName`, [`_Method`](../modules/pinia.md#_Method)\> ? (`resolvedReturn`: [`_Awaited`](../modules/pinia.md#_Awaited)\<`ReturnType`\<`A`[`ActionName`]\>\>) => `void` : () => `void`) => `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.
+
 #### Type declaration
 
 ▸ (`callback`): `void`
@@ -65,6 +68,9 @@ ___
 
 • **onError**: (`callback`: (`error`: `unknown`) => `void`) => `void`
 
+Sets up a hook if the action fails. Return `false` to catch the error and
+stop it from propagating.
+
 #### Type declaration
 
 ▸ (`callback`): `void`
index c975e3017a20440c67bc3c724e9f2931d294a54e..b28547807cf23e480b2ba5560ea2d9069ebd7541 100644 (file)
@@ -111,43 +111,10 @@ function that removes the watcher
 
 ▸ (): `void`
 
-Setups a callback to be called every time an action is about to get
-invoked. The callback receives an object with all the relevant information
-of the invoked action:
-- `store`: the store it is invoked on
-- `name`: The name of the action
-- `args`: The parameters passed to the action
-
-On top of these, it receives two functions that allow setting up a callback
-once the action finishes or when it fails.
-
-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
-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
- })
-})
-```
-
 **`Example`**
 
 ```js
@@ -242,12 +209,6 @@ 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
-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
 
 `void`
-
-function that removes the watcher
index 7ae2abcb0f1e1b95726a58c156fade646f30ca83..6b18f13971a2380f39611ccbd320d6dc5cfb2a05 100644 (file)
@@ -14,6 +14,10 @@ editLink: false
 
 • `Optional` **createSpy**: (`fn?`: (...`args`: `any`[]) => `any`) => (...`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 if
+`globals: true` is set.
+
 #### Type declaration
 
 ▸ (`fn?`): (...`args`: `any`[]) => `any`
index 959db867ad6477f2572b9b49ef0224e61f287375..0cb48eda53505e72e062be6a94bce7dc0b09dcc5 100644 (file)
@@ -115,6 +115,8 @@ ___
 
 Ƭ **StoreOnActionListener**\<`Id`, `S`, `G`, `A`\>: (`context`: [`StoreOnActionListenerContext`](pinia.md#StoreOnActionListenerContext)\<`Id`, `S`, `G`, {} extends `A` ? [`_ActionsTree`](pinia.md#_ActionsTree) : `A`\>) => `void`
 
+Argument of `store.$onAction()`
+
 #### Type parameters
 
 | Name | Type |
@@ -128,8 +130,6 @@ ___
 
 ▸ (`context`): `void`
 
-Argument of `store.$onAction()`
-
 ##### Parameters
 
 | Name | Type |
@@ -179,6 +179,8 @@ ___
 
 Ƭ **SubscriptionCallback**\<`S`\>: (`mutation`: [`SubscriptionCallbackMutation`](pinia.md#SubscriptionCallbackMutation)\<`S`\>, `state`: `UnwrapRef`\<`S`\>) => `void`
 
+Callback of a subscription
+
 #### Type parameters
 
 | Name |
@@ -189,8 +191,6 @@ ___
 
 ▸ (`mutation`, `state`): `void`
 
-Callback of a subscription
-
 ##### Parameters
 
 | Name | Type |
@@ -453,14 +453,14 @@ ___
 
 Ƭ **\_Method**: (...`args`: `any`[]) => `any`
 
-#### Type declaration
-
-▸ (`...args`): `any`
-
 Generic type for a function that can infer arguments and return type
 
 For internal use **only**
 
+#### Type declaration
+
+▸ (`...args`): `any`
+
 ##### Parameters
 
 | Name | Type |