import {Action, State, StateContext} from '@ngxs/store'; import {ViewDIP} from '@app/access/access.action'; export interface AccessStateModel { feed: boolean; dip: string; isLoading: boolean; } @State<AccessStateModel>({ name: 'access', defaults: { feed: false, dip: '', isLoading: false, }, }) export class AccessState { @Action(ViewDIP) viewDip(ctx: StateContext<AccessStateModel>, action: ViewDIP) { const state = ctx.getState(); // ctx.patchState() ctx.setState({ ...state, feed: !state.feed, dip: action.name, isLoading: true, }); } }