@telperion/ng-pack 1.3.2 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -18,15 +18,17 @@ npm install @telperion/ng-pack
|
|
|
18
18
|
|
|
19
19
|
**Import:** `@telperion/ng-pack/storage-signals`
|
|
20
20
|
|
|
21
|
-
Angular signals-based wrapper for browser's localStorage and
|
|
21
|
+
Angular signals-based wrapper for browser's localStorage, sessionStorage, and cookies with reactive updates.
|
|
22
22
|
|
|
23
23
|
#### Key Features
|
|
24
24
|
|
|
25
25
|
- 🚀 Signal-based API integrated with Angular's signal system
|
|
26
26
|
- 🔄 Reactive updates automatically synced across components
|
|
27
27
|
- 🎯 Nested property access using dot notation
|
|
28
|
-
- 🏪 Support for
|
|
28
|
+
- 🏪 Support for localStorage, sessionStorage, and cookies
|
|
29
29
|
- 🔑 Namespaced storage organization
|
|
30
|
+
- 🍪 Full cookie configuration (secure, sameSite, maxAge, etc.)
|
|
31
|
+
- 🔗 Cross-instance synchronization for cookie storage
|
|
30
32
|
|
|
31
33
|
#### Quick Start
|
|
32
34
|
|
|
@@ -60,6 +62,47 @@ export class SettingsComponent {
|
|
|
60
62
|
}
|
|
61
63
|
```
|
|
62
64
|
|
|
65
|
+
**Cookie Storage:**
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { ApplicationConfig } from '@angular/core';
|
|
69
|
+
import { provideCookieStorage } from '@telperion/ng-pack/storage-signals';
|
|
70
|
+
|
|
71
|
+
export const appConfig: ApplicationConfig = {
|
|
72
|
+
providers: [
|
|
73
|
+
provideCookieStorage('my-app', {
|
|
74
|
+
secure: true,
|
|
75
|
+
sameSite: 'strict',
|
|
76
|
+
maxAge: 86400 // 24 hours
|
|
77
|
+
}),
|
|
78
|
+
]
|
|
79
|
+
};
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { Component } from '@angular/core';
|
|
84
|
+
import { cookieStorageSignal } from '@telperion/ng-pack/storage-signals';
|
|
85
|
+
|
|
86
|
+
@Component({
|
|
87
|
+
selector: 'app-auth',
|
|
88
|
+
template: `
|
|
89
|
+
<div>
|
|
90
|
+
@if (authToken()) {
|
|
91
|
+
<button (click)="authToken.delete()">Logout</button>
|
|
92
|
+
} @else {
|
|
93
|
+
<button (click)="authToken.set('token123')">Login</button>
|
|
94
|
+
}
|
|
95
|
+
</div>
|
|
96
|
+
`
|
|
97
|
+
})
|
|
98
|
+
export class AuthComponent {
|
|
99
|
+
// Cookie with custom expiry
|
|
100
|
+
authToken = cookieStorageSignal<string>('auth', 'token', {
|
|
101
|
+
maxAge: 3600 // 1 hour
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
63
106
|
[Full documentation →](https://github.com/telperiontech/telperion/tree/main/libs/ng-pack/storage-signals)
|
|
64
107
|
|
|
65
108
|
---
|