Browse Source

feat: add ability to turn off devtools on vuex by passing an off options (#1407)

* Add ability to turn off devtools on vuex by passing an off options

* Swap order of precedence so that we use the options devtools over the vues devtools
Austin Story 6 years ago
parent
commit
be75d41cf5
2 changed files with 15 additions and 1 deletions
  1. 13 0
      docs/api/README.md
  2. 2 1
      src/store.js

+ 13 - 0
docs/api/README.md

@@ -116,6 +116,19 @@ const store = new Vuex.Store({ ...options })
 
 
   [Details](../guide/strict.md)
   [Details](../guide/strict.md)
 
 
+### devtools
+
+- 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. 
+
+  ``` js
+  {
+    devtools: false
+  }
+  ```
+
+
 ## Vuex.Store Instance Properties
 ## Vuex.Store Instance Properties
 
 
 ### state
 ### state

+ 2 - 1
src/store.js

@@ -63,7 +63,8 @@ export class Store {
     // apply plugins
     // apply plugins
     plugins.forEach(plugin => plugin(this))
     plugins.forEach(plugin => plugin(this))
 
 
-    if (Vue.config.devtools) {
+    const useDevtools = options.devtools !== undefined ? options.devtools : Vue.config.devtools
+    if (useDevtools) {
       devtoolPlugin(this)
       devtoolPlugin(this)
     }
     }
   }
   }