Pārlūkot izejas kodu

docs: document new subscribeAction options

Evan You 6 gadi atpakaļ
vecāks
revīzija
431540b463
1 mainītis faili ar 16 papildinājumiem un 1 dzēšanām
  1. 16 1
      docs/api/README.md

+ 16 - 1
docs/api/README.md

@@ -120,7 +120,7 @@ const store = new Vuex.Store({ ...options })
 
 - type: `Boolean`
 
-  Turn the devtools on or off for a particular vuex instance.  For instance passing false tells the Vuex store to not subscribe to devtools plugin.  Useful for if you have multiple stores on a single page. 
+  Turn the devtools on or off for a particular vuex instance.  For instance passing false tells the Vuex store to not subscribe to devtools plugin.  Useful for if you have multiple stores on a single page.
 
   ``` js
   {
@@ -207,6 +207,21 @@ const store = new Vuex.Store({ ...options })
 
   To stop subscribing, call the returned unsubscribe function.
 
+  > New in 3.1.0
+
+  Since 3.1.0, `subscribeAction` can also specify whether the subscribe handler should be called *before* or *after* an action dispatch (the default behavior is *before*):
+
+  ``` js
+  store.subscribeAction({
+    before: (action, state) => {
+      console.log(`before action ${action.type}`)
+    },
+    after: (action, state) => {
+      console.log(`after action ${action.type}`)
+    }
+  })
+  ```
+
   Most commonly used in plugins. [Details](../guide/plugins.md)
 
 ### registerModule