
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
@acpaas-ui/ngx-localstorage
Advanced tools
The `antwerp-ui localstorage` service allows you to easily store and retrieve data in and from your browsers storage.
The antwerp-ui localstorage
service allows you to easily store and retrieve data in and from your browsers storage.
import { LocalstorageModule } from '@acpaas-ui/ngx-localstorage';
Visit our documentation site for full how-to docs and guidelines
Method | Description |
---|---|
setItem(key: string, value: any): void | store an item in the localstorage and update the subscribers (all data is stringified to a JSON string). |
getItem<T = any>(key: string): T | retrieve an item from the localstorage (all data is parsed from a JSON string). |
removeItem(key: string): void | remove an item from the localstorage and update the subscribers. |
clear(...args): void | clear the localstorage. |
select<T = any>(selector: Selector, comparator: Comparator = LocalstorageHelper.comparator): BehaviorSubject<T> | get a BehaviorSubject containing the selected value. |
clearSubscribers(): void | unsubscribe all subscribers. |
You can set the preferred storage type in the forRoot
method when importing the LocalstorageModule
. The service will verify the type exists and fall back to localStorage
by default. If localStorage
is not available, an in-memory polyfill will be used.
You can provide a custom identifier that will be checked on instantiating the LocalstorageService
. If the identifier found in the storage is different from the config, the storage will be cleared.
This way, you can invalidate your apps storage to prevent data conflicts.
import { LocalstorageModule } from '@acpaas-ui/ngx-localstorage';
@NgModule({
imports: [
LocalstorageModule.forRoot({
storageType: 'sessionStorage',
identifier: 'my-app-v1',
})
]
});
export class AppModule {};
import { LocalstorageService } from '@acpaas-ui/ngx-localstorage';
public user: any;
public item: any;
public timesUsed: any;
constructor(
private localstorageService: LocalstorageService
) {
this.user = this.localstorageService.select('user');
this.timesUsed = 0;
this.localstorageService.setItem('number', this.timesUsed);
}
public loggedIn(): void {
this.localstorageService.setItem('user', 'You are logged in');
}
public loggedOut(): void {
this.localstorageService.setItem('user', 'You are logged out');
}
public init(): void {
this.localstorageService.removeItem('user');
this.timesUsed = this.timesUsed + 1;
this.localstorageService.setItem('number', this.timesUsed);
}
public clear(): void {
this.localstorageService.clear('user', 'number');
}
public getItem(): any {
this.item = this.localstorageService.getItem('user');
this.timesUsed = this.localstorageService.getItem('number');
}
<div class="u-margin-bottom">
<button type="button" (click)="loggedIn()" class="a-button u-margin-right">
Log in
</button>
<button type="button" (click)="loggedOut()" class="a-button u-margin-right">
Log out
</button>
<button type="button" (click)="init()" class="a-button u-margin-right">
Count clicks
</button>
</div>
<div class="u-margin-bottom">
<button type="button" (click)="getItem()" class="a-button u-margin-right">
Get from local storage
</button>
<button type="button" (click)="clear()" class="a-button">
Clear local storage
</button>
</div>
<div class="u-margin-bottom">
<label class="a-input__label a-input__label--inline">{{ this.item }}</label>
</div>
<div class="u-margin-bottom">
<label class="a-input__label a-input__label--inline">You clicked the count clicks button this many times: {{ this.timesUsed }}</label>
</div>
Visit our Contribution Guidelines for more information on how to contribute.
FAQs
The `antwerp-ui localstorage` service allows you to easily store and retrieve data in and from your browsers storage.
We found that @acpaas-ui/ngx-localstorage demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 10 open source maintainers 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
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.