From 5a1d38cb65d4d638edb6c616dd31ee910ddd4f10 Mon Sep 17 00:00:00 2001 From: ktsn Date: Mon, 19 Mar 2018 23:37:21 +0900 Subject: [PATCH 1/3] docs: improve wording in store#watch description (fix #1141) --- docs/en/api.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/api.md b/docs/en/api.md index 63ce2fa86..a02c7bdbc 100644 --- a/docs/en/api.md +++ b/docs/en/api.md @@ -140,9 +140,9 @@ 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)`** - 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. From b2faf37caa596a6e8e308fc1ddfd237b0231bb31 Mon Sep 17 00:00:00 2001 From: ktsn Date: Mon, 19 Mar 2018 23:41:07 +0900 Subject: [PATCH 2/3] docs: add description how to unsubscribe mutations/actions (fix #1194) --- docs/en/api.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/en/api.md b/docs/en/api.md index a02c7bdbc..af11d0688 100644 --- a/docs/en/api.md +++ b/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(fn: Function, callback: Function, options?: Object)`** +- **`watch(fn: Function, callback: Function, options?: Object): Function`** 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 handler 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 handler 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 handler function. + Most commonly used in plugins. [Details](plugins.md) - **`registerModule(path: string | Array, module: Module, options?: Object)`** From e277b58dffb9ca86f316e29136124a0d355c575d Mon Sep 17 00:00:00 2001 From: ktsn Date: Thu, 29 Mar 2018 13:45:22 +0900 Subject: [PATCH 3/3] docs: handle -> unwatch/unsubscribe --- docs/en/api.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en/api.md b/docs/en/api.md index af11d0688..b6b681fcd 100644 --- a/docs/en/api.md +++ b/docs/en/api.md @@ -144,7 +144,7 @@ const store = new Vuex.Store({ ...options }) 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 handler function. + To stop watching, call the returned unwatch function. - **`subscribe(handler: Function): Function`** @@ -157,7 +157,7 @@ const store = new Vuex.Store({ ...options }) }) ``` - To stop subscribing, call the returned handler function. + To stop subscribing, call the returned unsubscribe function. Most commonly used in plugins. [Details](plugins.md) @@ -174,7 +174,7 @@ const store = new Vuex.Store({ ...options }) }) ``` - To stop subscribing, call the returned handler function. + To stop subscribing, call the returned unsubscribe function. Most commonly used in plugins. [Details](plugins.md)