You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 28, 2025. It is now read-only.
Note that it's the best to configure this right after installation, because the data saved under keys with previous prefix won't be automatically read anymore - to prevent that you can change keys of already stored data or override them manually.
28
37
29
-
3. Use the `LocalStorage` or `SessionStorage` decorator
38
+
## How to use
39
+
40
+
1. Use the `@LocalStorage()` and/or `@SessionStorage()` decorator functions. Here is where the magic happens, decorated variables' values will be restored from the storage when you reload the site!
If you need to modify stored object in ways that can't be automatically handled (generally changing object properties or array elements using index signature),
42
-
and don't want to use Service, then you can take advantage of `.save()` method to force save introduced changes. Example:
63
+
2. **Force save changes.** If you need to modify stored object by not a direct assignment, then you can take advantage of `.save()` method to force save introduced changes. Example:
public menuItems = [{title: 'Menu1'}, {title: 'Menu2'}, {title: 'Menu3'}];
116
-
117
-
//here happens the magic. `hiddenMenuItems` is always restored from the localstorage when you reload the site
118
-
@LocalStorage() public hiddenMenuItems:Array<boolean> = [];
119
-
120
-
//here happens the magic. `profile` is always restored from the sessionStorage when you reload the site from the current tab/browser. This is perfect for more sensitive information that shouldn't stay once the user closes the browser.
121
-
@SessionStorage() public profile:any= {};
122
-
}
123
-
```
97
+
### TODO
98
+
- Try to automatically handle all data manipulations using [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
0 commit comments