Skip to content

Commit 432487b

Browse files
authored
docs: improve API reference of watch and subscribe (#1195)
* docs: improve wording in store#watch description (fix #1141) * docs: add description how to unsubscribe mutations/actions (fix #1194) * docs: handle -> unwatch/unsubscribe
1 parent d8c145e commit 432487b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

docs/en/api.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,13 @@ const store = new Vuex.Store({ ...options })
140140
141141
Replace the store's root state. Use this only for state hydration / time-travel purposes.
142142
143-
- **`watch(getter: Function, cb: Function, options?: Object)`**
143+
- **`watch(fn: Function, callback: Function, options?: Object): Function`**
144144
145-
Reactively watch a getter function's return value, and call the callback when the value changes. The getter receives the store's state as the first argument, and getters as the second argument. Accepts an optional options object that takes the same options as Vue's `vm.$watch` method.
145+
Reactively watch `fn`'s return value, and call the callback when the value changes. `fn` receives the store's state as the first argument, and getters as the second argument. Accepts an optional options object that takes the same options as Vue's `vm.$watch` method.
146146
147-
To stop watching, call the returned handle function.
147+
To stop watching, call the returned unwatch function.
148148
149-
- **`subscribe(handler: Function)`**
149+
- **`subscribe(handler: Function): Function`**
150150
151151
Subscribe to store mutations. The `handler` is called after every mutation and receives the mutation descriptor and post-mutation state as arguments:
152152
@@ -157,9 +157,11 @@ const store = new Vuex.Store({ ...options })
157157
})
158158
```
159159
160+
To stop subscribing, call the returned unsubscribe function.
161+
160162
Most commonly used in plugins. [Details](plugins.md)
161163
162-
- **`subscribeAction(handler: Function)`**
164+
- **`subscribeAction(handler: Function): Function`**
163165
164166
> New in 2.5.0
165167
@@ -172,6 +174,8 @@ const store = new Vuex.Store({ ...options })
172174
})
173175
```
174176
177+
To stop subscribing, call the returned unsubscribe function.
178+
175179
Most commonly used in plugins. [Details](plugins.md)
176180
177181
- **`registerModule(path: string | Array<string>, module: Module, options?: Object)`**

0 commit comments

Comments
 (0)