From 1e91f41575195f401ba2ab5ef024a4d6d67bf6c4 Mon Sep 17 00:00:00 2001 From: Kia Ishii Date: Fri, 8 May 2020 18:01:40 +0900 Subject: [PATCH 1/2] docs: add docs for the new `error` option for `subscribeAction` method --- docs/api/README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/api/README.md b/docs/api/README.md index e666255a4..f901ba35a 100644 --- a/docs/api/README.md +++ b/docs/api/README.md @@ -233,7 +233,20 @@ const store = new Vuex.Store({ ...options }) }) ``` - Most commonly used in plugins. [Details](../guide/plugins.md) + > New in 3.4.0 + + Since 3.4.0, `subscribeAction` can also specify the `error` option to catch the error thrown during the action dispatch. The `error` option will take an additional `error` object as the 3rd argument. + + ``` js + store.subscribeAction({ + after: (action, state, error) => { + console.log(`error action ${action.type}`) + console.error(error) + } + }) + ``` + + The `subscribeAction` method is most commonly used in plugins. [Details](../guide/plugins.md) ### registerModule From c2ad79e2bd621915b7e5a75cffdd2b49e5dcbddf Mon Sep 17 00:00:00 2001 From: Kia Ishii Date: Sat, 9 May 2020 14:37:43 +0900 Subject: [PATCH 2/2] docs: fix typos --- docs/api/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api/README.md b/docs/api/README.md index f901ba35a..6a29c1d4d 100644 --- a/docs/api/README.md +++ b/docs/api/README.md @@ -235,11 +235,11 @@ const store = new Vuex.Store({ ...options }) > New in 3.4.0 - Since 3.4.0, `subscribeAction` can also specify the `error` option to catch the error thrown during the action dispatch. The `error` option will take an additional `error` object as the 3rd argument. + Since 3.4.0, `subscribeAction` can also specify an `error` handler to catch an error thrown when an action is dispatched. The function will receive an `error` object as the third argument. ``` js store.subscribeAction({ - after: (action, state, error) => { + error: (action, state, error) => { console.log(`error action ${action.type}`) console.error(error) }