Skip to content

Commit 4e6b9b6

Browse files
authored
docs: Update pinia._StoreWithState.md (#2974)
Delete duplicate information in the document.
1 parent 98c6419 commit 4e6b9b6

File tree

1 file changed

+3
-36
lines changed

1 file changed

+3
-36
lines changed

packages/docs/zh/api/interfaces/pinia._StoreWithState.md

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -96,30 +96,14 @@ Store 的 State。给它赋值可替换整个 state。
9696
请注意,当在组件内调用 `store.$onAction()` 时,除非 `detached` 被设置为 true,
9797
否则当组件被卸载时,它将被自动清理掉。
9898

99-
**`Example`**
100-
101-
```js
102-
store.$onAction(({ after, onError }) => {
103-
// 你可以在这里创建所有钩子之间的共享变量,
104-
// 同时设置侦听器并清理它们。
105-
after((resolvedValue) => {
106-
// 可以用来清理副作用
107-
// `resolvedValue` 是 action 返回的值,
108-
// 如果是一个 Promise,它将是已经 resolved 的值
109-
})
110-
onError((error) => {
111-
// 可以用于向上传递错误
112-
})
113-
})
114-
```
115-
11699
#### 参数
117100

118101
| 名称 | 类型 | 描述 |
119102
| :---------- | :----------------------------------------------------------------------------------------- | :----------------------------------------------------------- |
120103
| `callback` | [`StoreOnActionListener`](../modules/pinia.md#storeonactionlistener)<`Id`, `S`, `G`, `A`\> | callback called before every action |
121104
| `detached?` | `boolean` | detach the subscription from the context this is called from |
122105

106+
123107
#### 返回值
124108

125109
`fn`
@@ -128,20 +112,9 @@ store.$onAction(({ after, onError }) => {
128112

129113
▸ (): `void`
130114

131-
设置一个回调,当一个 action 即将被调用时,就会被调用。
132-
回调接收一个对象,
133-
其包含被调用 action 的所有相关信息:
134-
135-
- `store`: 被调用的 store
136-
- `name`: action 的名称
137-
- `args`: 传递给 action 的参数
138-
139-
除此之外,它会接收两个函数,
140-
允许在 action 完成或失败时执行的回调。
115+
##### 返回值
141116

142-
它还会返回一个用来来删除回调的函数。
143-
请注意,当在组件内调用 `store.$onAction()` 时,除非 `detached` 被设置为 true,
144-
否则当组件被卸载时,它将被自动清理掉。
117+
`void`
145118

146119
**`Example`**
147120

@@ -160,12 +133,6 @@ store.$onAction(({ after, onError }) => {
160133
})
161134
```
162135

163-
##### 返回值
164-
165-
`void`
166-
167-
移除侦听器的函数
168-
169136
---
170137

171138
### $patch %{#patch}%

0 commit comments

Comments
 (0)