1
0
Эх сурвалжийг харах

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
katashin 7 жил өмнө
parent
commit
432487b3e4
1 өөрчлөгдсөн 9 нэмэгдсэн , 5 устгасан
  1. 9 5
      docs/en/api.md

+ 9 - 5
docs/en/api.md

@@ -140,13 +140,13 @@ const store = new Vuex.Store({ ...options })
 
   Replace the store's root state. Use this only for state hydration / time-travel purposes.
 
-- **`watch(getter: Function, cb: Function, options?: Object)`**
+- **`watch(fn: Function, callback: Function, options?: Object): Function`**
 
-  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.
+  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.
 
-  To stop watching, call the returned handle function.
+  To stop watching, call the returned unwatch function.
 
-- **`subscribe(handler: Function)`**
+- **`subscribe(handler: Function): Function`**
 
   Subscribe to store mutations. The `handler` is called after every mutation and receives the mutation descriptor and post-mutation state as arguments:
 
@@ -157,9 +157,11 @@ const store = new Vuex.Store({ ...options })
   })
   ```
 
+  To stop subscribing, call the returned unsubscribe function.
+
   Most commonly used in plugins. [Details](plugins.md)
 
-- **`subscribeAction(handler: Function)`**
+- **`subscribeAction(handler: Function): Function`**
 
   > New in 2.5.0
 
@@ -172,6 +174,8 @@ const store = new Vuex.Store({ ...options })
   })
   ```
 
+  To stop subscribing, call the returned unsubscribe function.
+
   Most commonly used in plugins. [Details](plugins.md)
 
 - **`registerModule(path: string | Array<string>, module: Module, options?: Object)`**