From 3ef3fb1852012d061f20327fad0db772c0cbf931 Mon Sep 17 00:00:00 2001 From: Austin Story Date: Tue, 25 Sep 2018 11:44:02 -0500 Subject: [PATCH 1/2] Add ability to turn off devtools on vuex by passing an off options --- docs/api/README.md | 13 +++++++++++++ src/store.js | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/api/README.md b/docs/api/README.md index 906167686..161d0511e 100644 --- a/docs/api/README.md +++ b/docs/api/README.md @@ -116,6 +116,19 @@ const store = new Vuex.Store({ ...options }) [Details](../guide/strict.md) +### devtools + +- type: `Boolean` + + Passing false tells the Vuex store to not subscribe to devtools plugin. By default uses the Vue instances devtools setting. Useful for if you have multiple stores on a single page. + + ``` js + { + devtools: false + } + ``` + + ## Vuex.Store Instance Properties ### state diff --git a/src/store.js b/src/store.js index b5b083c92..aba841e9b 100644 --- a/src/store.js +++ b/src/store.js @@ -63,7 +63,7 @@ export class Store { // apply plugins plugins.forEach(plugin => plugin(this)) - if (Vue.config.devtools) { + if (Vue.config.devtools && options.devtools !== false) { devtoolPlugin(this) } } From ea6b645d630b4e3d5f5ddf4322389286f1a6fb33 Mon Sep 17 00:00:00 2001 From: Austin Story Date: Sun, 30 Sep 2018 07:49:06 -0500 Subject: [PATCH 2/2] Swap order of precedence so that we use the options devtools over the vues devtools --- docs/api/README.md | 2 +- src/store.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/api/README.md b/docs/api/README.md index 161d0511e..865e92f63 100644 --- a/docs/api/README.md +++ b/docs/api/README.md @@ -120,7 +120,7 @@ const store = new Vuex.Store({ ...options }) - type: `Boolean` - Passing false tells the Vuex store to not subscribe to devtools plugin. By default uses the Vue instances devtools setting. 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 { diff --git a/src/store.js b/src/store.js index aba841e9b..4251eaa73 100644 --- a/src/store.js +++ b/src/store.js @@ -63,7 +63,8 @@ export class Store { // apply plugins plugins.forEach(plugin => plugin(this)) - if (Vue.config.devtools && options.devtools !== false) { + const useDevtools = options.devtools !== undefined ? options.devtools : Vue.config.devtools + if (useDevtools) { devtoolPlugin(this) } }