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

blacklist functionality broken? #19

Open
zciendor opened this issue Jan 20, 2019 · 3 comments
Open

blacklist functionality broken? #19

zciendor opened this issue Jan 20, 2019 · 3 comments

Comments

@zciendor
Copy link

zciendor commented Jan 20, 2019

First, let's look at what is working as expected:

createPersistedState({
  blacklist: (mutation) => {
    return true
  }
})

This will never persist any state. However, this is a bit pointless as the same result could be achieved by not using the createPersistedState plugin at all.

Now let's look at the case when blacklisting certain mutations, by providing a list of mutations:

createPersistedState({
  blacklist: ["ignoredMutation"],
})

Well, it's true that the state is not persisted when ignoredMutation is fired. However, the whole state will be persisted the next time a non-blacklisted mutation is triggered - which includes all the previous mutations, even the blacklisted ones. Basically you're only delaying persistence that way but not blacklisting it.

So the question is: Is this implemented as designed? If yes, where's the point in that?
The only use I can imagine is that it allows you to blacklist certain mutations for performance reasons (e.g. in case they are triggered that often that you don't want to write to the persistence file every time). But I doubt that this is what users would expect based on the limited documentation.

@MaverickMartyn
Copy link

I would like an update to this as well.
I am currently having issues where one of my state items is updated very frequently, and I would like to not persist it to disk.
I often have permission issues, since the file is already being modified, and I think this could fix it.

@MaverickMartyn
Copy link

MaverickMartyn commented Jan 31, 2019

@zciendor Update:
You can take a look at my fork, and use that until this is fixed (I created a pull request containing my fix).
In my fork, you can use the "ignorePaths" option to avoid persisting specific parts of the state object.
It just takes an array of strings. An example could be ["module.statevalue.anothervalue"].
You can combine it with the existing blacklist functionality, to also block mutations.
If you do not block the mutations, the rest of the state will still be saved, just not any blocked values.
This could be an issue with state items that are often mutated.
So I recommend using both. :)

@akodkod
Copy link
Contributor

akodkod commented Aug 29, 2019

#44

Rhilip added a commit to Rhilip/IYUU-GUI that referenced this issue Jul 17, 2020
vuex-electron存在很一个严重的问题。即使添加了blacklist,但是在下次非blacklist的commit的时候,还是会把所有的state进行持久化。鉴于vuex-electron已经不做维护,使用 MaverickMartyn/vuex-electron 作为替代

refs: vue-electron/vuex-electron#19
refs: vue-electron/vuex-electron#22
refs: https://github.com/MaverickMartyn/vuex-electron
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

No branches or pull requests

3 participants