import { Action , Selector , State , StateContext } from '@ngxs/store' ; export type Alert = { message ? : string ; color ? : string ; show ? : boolean ; } ; export class GlobalStateModel { alert : Alert ; } export namespace GlobalActions { export class setAlert { static readonly type = '[Alert] SetAlert' ; constructor ( public payload ) { } } } @ State < GlobalStateModel > ( { name : 'global' , defaults : { alert : null , } , } ) export class GlobalState { @ Selector ( ) static getAlert ( state ) { return state . alert ; } @ Action ( GlobalActions . setAlert ) setAlert ( { patchState } , action ) { let alert = action . payload ; console . log ( "Setting alert " , alert ) ; patchState ( { alert : alert , } ) ; } }