This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createReducer, on } from '@ngrx/store'; | |
import { setLoginStateSuccess, setErrorMessage } from '../login/login.action'; | |
// ↑↑↑このactionを追加 | |
export interface LoginModel { | |
isLogin: boolean; | |
errorMessage?: string; | |
} | |
export const initialState: LoginModel = { isLogin: false }; | |
// ここから下が追加 | |
export const loginReducer = createReducer( | |
initialState, // 最初に初期化する、ここから下がそれぞれの処理 | |
on(setLoginStateSuccess, (state, { isLogin }) => { // setLoginStateSuccessアクションの処理、引数はisLogin | |
return ({...state, isLogin }); // 必ず最初は、...state。次にセットしたい情報(isLogin) | |
}), | |
on(setErrorMessage, (state, { errorMessage }) => { // ここもsetLoginStateSuccessアクションと同じ感じ | |
return ({ ...state, errorMessage }); | |
}), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment