-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to turn off devtools on vuex by passing an off options #1407
Conversation
src/store.js
Outdated
@@ -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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it may be cleaner to use Vue.config.devtools
as default value of options.devtools
rather than conjunction of both. like:
const devtools = options.devtools !== undefined ? options.devtools : Vue.config.devtools
// ...
if (devtools) {
// ...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had thought about this approach as well. I ended up on this way because i think we want to respect someone turning it off in Vue, which acts more like a parent here.
I could see both side of it though, what do you think from that perspective?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the point as well. But I personally still feel that the default value is better because of intuitiveness. I'm concerning that the user may be confused if Vue's devtools config overwrites Vuex's one when they are not sure about that behavior. I also don't come up with any use cases for the behavior. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, so if someone has this set to true in dev but ships to prod. It would still attach to the vue devtools if VUE_DEVTOOLS_GLOBAL_HOOK exists (have saw this exist before when vue devtools are off.)
Going to switch around to your recommendation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ktsn updated ⬆️
Thanks! |
This PR adds the ability to turn off devtools on a per vuex instance level. This is useful for cases where you have multiple vuex stores on a single page. A good example is a scenario where teams maintain their own portions of a single app that are all loaded, some of which will have an independent vuex store.
With this option, on the dev side i could turn this off per instance so that I can debug a single store.
By default, this mirrors what is already in vuex, it just allows for turning off when specified.
Follow through on #875