Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@ngxs-labs/select-snapshot
Advanced tools
Flexibile decorator, an alternative for the
@Select
but selects a snapshot of the state
To install @ngxs-labs/select-snapshot
run the following command:
npm install @ngxs-labs/select-snapshot
# of if you use yarn
yarn add @ngxs-labs/select-snapshot
Import the NgxsSelectSnapshotModule
into your root application module:
import { NgModule } from '@angular/core';
import { NgxsModule } from '@ngxs/store';
import { NgxsSelectSnapshotModule } from '@ngxs-labs/select-snapshot';
@NgModule({
imports: [NgxsModule.forRoot(states), NgxsSelectSnapshotModule.forRoot()],
})
export class AppModule {}
The @SelectSnapshot
is just a simple decorator same as @Select
. It allows you to decorate properties of your classes applying new getter and lets you to avoid injecting Store
class everywhere. Simple example, let's create some tiny pandas
state:
import { State, Action, StateContext } from '@ngxs/store';
class AddPanda {
static type = '[Pandas] Add panda';
constructor(public panda: string) {}
}
@State<string[]>({
name: 'pandas',
defaults: [],
})
export class PandasState {
@Action(AddPanda)
addPanda(ctx: StateContext<string[]>, action: AddPanda): void {
const pandas = ctx.getState();
ctx.setState([...pandas, action.panda]);
}
}
Assume you've provided this state into your root NgxsModule
and want already to try the @SelectSnapshot
decorator:
import { Component } from '@angular/core';
import { SelectSnapshot } from '@ngxs-labs/select-snapshot';
import { PandasState } from './pandas.state';
@Component({
selector: 'app-root',
template: '<app-panda *ngFor="let panda of pandas" [panda]="panda"></app-panda>',
})
export class AppComponent {
@SelectSnapshot(PandasState) pandas: string[];
}
The @SelectSnapshot
decorator has the same API as the @Select
decorator. It accepts state class, selector function, string or nothing as an argument.
FAQs
Unknown package
We found that @ngxs-labs/select-snapshot demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.