Skip to content
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

Merged
merged 2 commits into from Oct 2, 2018

Conversation

Austio
Copy link
Contributor

@Austio Austio commented Sep 25, 2018

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.

const store = new Vuex.Store({
  devtools: false
})

Follow through on #875

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) {
Copy link
Member

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) {
  // ...
}

Copy link
Contributor Author

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?

Copy link
Member

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. 🤔

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ktsn updated ⬆️

@ktsn ktsn merged commit be75d41 into vuejs:dev Oct 2, 2018
@ktsn
Copy link
Member

ktsn commented Oct 2, 2018

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants