Skip to content

Instantly share code, notes, and snippets.

@advorkina
Last active January 3, 2019 13:03
Show Gist options
  • Save advorkina/9bcabaf50d69fcc1f2496a50f21b9999 to your computer and use it in GitHub Desktop.
Save advorkina/9bcabaf50d69fcc1f2496a50f21b9999 to your computer and use it in GitHub Desktop.
import { State, Action, StateContext } from '@ngxs/store';
import { Open } from './actions/home.actions';
interface IHomeState {
isOpen: boolean;
}
@State<IHomeState>({
name: 'home',
defaults: {
isOpen: false
}
})
export class HomeState {
@Action(Open)
open(ctx: StateContext<IHomeState>) {
const state = ctx.getState();
ctx.setState({
...state,
isOpen: true
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment