12 - Strong Typing the State and Actions
In this section we explore Strongly Typing the State and Actions
1. Add Login Action Creators
import { createAction, props } from '@ngrx/store';
import { Authenticate, User } from '@demo-app/data-models';
export enum AuthActionTypes {
Login = '[Auth Page] Login',
LoginSuccess = '[Auth API] Login Success',
LoginFail = '[Auth API] Login Fail'
}
export const login = createAction(
AuthActionTypes.Login,
props<{ payload: Authenticate }> ()
);
export const loginSuccess = createAction(
AuthActionTypes.LoginSuccess,
props<{ payload: User }>()
);
export const loginFailure = createAction(
AuthActionTypes.LoginFail,
props<{ payload: any }>()
);Action Hygiene
2. Add default state and interface
Last updated