Update README.md
This commit is contained in:
parent
3262a76cfd
commit
730b35cdfd
30
README.md
30
README.md
@ -1 +1,31 @@
|
|||||||
# WebStorage
|
# WebStorage
|
||||||
|
|
||||||
|
A Javascript library that adds property decorators to sync a class property with the local & session storage. It also includes crypto-js so that sensitive information being stored on the client is not stored in plain text.
|
||||||
|
|
||||||
|
### Quick Setup
|
||||||
|
1. Install with: `npm install --save webstorage-decorators crypto-js`
|
||||||
|
2. Add the decorator to your property and you are done!
|
||||||
|
```
|
||||||
|
import {LocalStorage, SessionStorage} from 'webstorage-decorators';
|
||||||
|
|
||||||
|
export class SomeComponent {
|
||||||
|
|
||||||
|
@LocalStorage({
|
||||||
|
fieldName: 'customName',
|
||||||
|
encryptionKey: settings.encryptionToken,
|
||||||
|
defaultValue: 123
|
||||||
|
})
|
||||||
|
someProperty;
|
||||||
|
|
||||||
|
@SessionStorage(/* Accepts same optional paramters as the LocalStorage*/) user;
|
||||||
|
|
||||||
|
constructor(user) {
|
||||||
|
// This property will get its vallue from the local storage or default to 123 if the property doesn't exist
|
||||||
|
console.log(this.someProperty)
|
||||||
|
|
||||||
|
// Because of our SessionStorage decorator the user is automatically stored in the session storage
|
||||||
|
this.user = user
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user