vuex-multi-tab-state
vuex-multi-tab-state copied to clipboard
Misleading documentation of onBeforeReplace and onBeforeSave
Hello,
I am looking for a way how to prevent the plugin from overwriting my state from the local storage if some condition matches. I think I found a solution by returning a falsy value from the onBeforeReplace
hook, as that seems to prevent the replacement of the local vuex state. This behavior is also confirmed by the following test: https://github.com/gabrielmbmb/vuex-multi-tab-state/blob/master/test/test.spec.ts#L298
In contrast, the documentation of onBeforeReplace
in the readme states the following:
hook function that receives the state and allows to modify it before replacing it. The function can return either a modified state or a falsy value (which means that no modifications has been done inside the hook)
From this documentation I cannot infer that the local state will not be updated when returning a falsy value. My first understanding of this sentence was, that returning a falsy value will just take the value from the local storage and overwrite the state without any modifications by the hook. The same misleading formulation is present in the documentation of onBeforeSave
.
Is my understanding of the hooks correct? If yes, I am happy to contribute a better formulation for the readme.