Life-cycle
ngxsOnInit
ngxsOnInitexport interface ZooStateModel {
animals: string[];
}
@State<any[]>({
name: 'zoo',
defaults: {
animals: []
}
})
export class ZooState implements NgxsOnInit {
ngxsOnInit(ctx: StateContext<ZooStateModel>) {
console.log('State initialized, now getting animals');
ctx.dispatch(new GetAnimals());
}
}Last updated

