export interface User { auth? : boolean id? : number name? : string password? : string }
import { Actions, userLogin, userLogout } from '../actions/auth.actions' import { User } from '../../models/user.model' const initialState: User = { auth: false } export function authReducer(state : User = initialState, action : Actions) { switch(action.type) { case userLogin: state.auth = true return state case userLogout: state.auth = false return state default: return state } }
import { Injectable } from '@angular/core' import { Action } from '@ngrx/store' import { User } from '../../models/user.model' export const userLogin = 'userLogin' export const userLogout = 'userLogout' export class setLogin implements Action { readonly type = userLogin constructor() {} } export class setLogout implements Action { readonly type = userLogout constructor() {} } export type Actions = setLogin | setLogout
import { User } from '../models/user.model' export interface AppState { readonly user : User }