Updated docs

This commit is contained in:
Zakary Timson 2021-02-02 00:05:08 -05:00
parent e339af3874
commit f27014af14
2 changed files with 6 additions and 5 deletions

View File

@ -9,14 +9,15 @@ for persisting themes or local settings over reloads or maintaining filters/sear
import {LocalStorage, SessionStorage} from 'webstorage-decorators';
export class MyCustomClass {
@LocalStorage({key: 'site_theme', default: 'light_theme'}) theme: string;
@SessionStorage({encryptWith: config.entryptionKey}) thisUser: User;
@LocalStorage('light_theme', {key: 'site_theme'}) theme: string;
@SessionStorage(null, {encryptWith: config.entryptionKey}) thisUser: User;
@SessionStorage() searchBar: string;
constructor() {
constructor() {
console.log(this.theme, localStorage.getItem('theme')); // Output: 'light_theme', 'light_theme'
console.log(this.user, localStorage.getItem('user')); // Output: null, undefined
user = {first: 'John', last: 'Smith', ...}
console.log(this.user, this.user == localStorage.getItem('user')); // Output: {first: 'John', last: 'Smith', ...}, true
console.log(this.user, localStorage.getItem('user')); // Output: {first: 'John', last: 'Smith', ...}, **Some encrypted value**
}
}
```

View File

@ -1,6 +1,6 @@
{
"name": "webstorage-decorators",
"version": "3.2.5",
"version": "3.2.6",
"description": "Decorators to sync class properties to Local/Session storage",
"repository": "https://github.com/ztimson/WebstorageDecorators",
"main": "./lib/index.js",