]> juplo.de Git - demos/angular/stored-login/commitdiff
refacotr: using `undefined` instead of `null` in all places
authorKai Moritz <kai@juplo.de>
Mon, 15 Sep 2025 20:52:49 +0000 (22:52 +0200)
committerKai Moritz <kai@juplo.de>
Mon, 15 Sep 2025 20:52:49 +0000 (22:52 +0200)
src/app/login/login.component.ts
src/app/store/login.actions.ts
src/app/store/login.reducers.ts

index bbaf374b1ca32bab1a731828822240be12af1b03..9c4f8a5229dc4ae8b87d73afd6c411e25000ca84 100644 (file)
@@ -18,7 +18,7 @@ export class LoginComponent {
   private store = inject(Store);
 
   form: FormGroup;
-  error: string|null = null;
+  error: string|undefined = undefined;
   isLoading : boolean = false;
 
   constructor(private fb: FormBuilder) {
index ba6e195807553f72b1553ba8375fa604e642e11c..131940825478ea217e49bbb862936fce3e186722 100644 (file)
@@ -2,7 +2,7 @@ import { createAction, props } from '@ngrx/store';
 
 export const login = createAction(
   '[Login] User Login',
-  props<{ username: string|null, password: string|null }>()
+  props<{ username: string|undefined, password: string|undefined }>()
 );
 
 export const loginSuccess = createAction(
index 951624abeb4e173811cb340bd782dbadda3a30cf..98ce5fcadedde10f6f71e63a24509f67f81b4066 100644 (file)
@@ -2,19 +2,19 @@ import { createReducer, on } from '@ngrx/store';
 import { login, loginFailure, loginSuccess } from './login.actions';
 
 export interface State {
-  token: string|null;
-  error: string|null;
+  token: string|undefined;
+  error: string|undefined;
   isLoading: boolean;
 }
 
 const initialState: State = {
-  token: null,
-  error: null,
+  token: undefined,
+  error: undefined,
   isLoading: false
 };
 
 export const loginReducers = createReducer(initialState,
   on(login, state => ({ ...state, isLoading: true })),
-  on(loginSuccess, (state, { token }) => ({ ...state, token, error: null, isLoading: false })),
-  on(loginFailure, (state, { error }) => ({ ...state, token: null, error, isLoading: false }))
+  on(loginSuccess, (state, { token }) => ({ ...state, token, error: undefined, isLoading: false })),
+  on(loginFailure, (state, { error }) => ({ ...state, token: undefined, error, isLoading: false }))
 );