Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
vue-save-state
Advanced tools
Changelog
1.2.0 - 2017-04-28
ignoreProperties
optionReadme
This package provides a SaveState
mixin that automatically saves any change in the state of your component to localStorage. The next time that component gets initialized it will restore its state from the saved values in local storage.
Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.
You're free to use this package (it's MIT-licensed), but if it makes it to your production environment we highly apprecatie you sending us a postcard from your hometown, mentioning which of our package(s) you are using.
Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.
All postcards are published on our website.
You can install the package via yarn:
yarn add vue-save-state
or npm
npm install vue-save-state
In order to save the state of your component you'll need to add the SaveState
mixin:
import saveState from 'vue-save-state';
export default {
mixins: [saveState],
...
}
Next you'll need to add a method called getSaveStateConfig
:
import saveState from 'vue-save-state';
export default {
mixins: [saveState],
// ...
methods: {
getSaveStateConfig() {
return {
'cacheKey': 'nameOfYourComponent',
};
},
},
}
With these steps done any change to the state of your component will get written to local storage. The value given in cacheKey
determines to which key in local storage the state of this component will get written. When the component is created it'll restore its state from local storage.
There's also a configuration option to determine which properties of the state should be saved/restored:
import saveState from 'vue-save-state';
export default {
// ...
methods: {
getSaveStateConfig() {
return {
'cacheKey': 'nameOfYourComponent',
'saveProperties': ['title', 'text'],
};
},
},
}
With this configuration only the title
and text
properties of your state will get saved/restored.
Alternatively you could specify which fields to ignore:
import saveState from 'vue-save-state';
export default {
// ...
methods: {
getSaveStateConfig() {
return {
'cacheKey': 'nameOfYourComponent',
'ignoreProperties': ['title'],
};
},
},
}
In this scenario all fields except for the title
property in your state will get saved/restored.
If you want to transform the values stored in local storage before loading the into the state of the component add an onLoad
function to the object return by getSaveStateConfig
.
import saveState from 'vue-save-state';
export default {
// ...
methods: {
getSaveStateConfig() {
return {
'onLoad': (key, value) => {
//return a new value
},
};
},
},
}
Please see CHANGELOG for more information what has changed recently.
$ npm run test
Please see CONTRIBUTING for details.
If you discover any security related issues, please contact Freek Van der Herten instead of using the issue tracker.
Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.
The MIT License (MIT). Please see License File for more information.
FAQs
A Vue mixin to save the state of a component to local storage
The npm package vue-save-state receives a total of 370 weekly downloads. As such, vue-save-state popularity was classified as not popular.
We found that vue-save-state demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.