Created
January 29, 2022 02:54
-
-
Save ksakae1216/1118b9c4ac794faf14fd913456f7ea08 to your computer and use it in GitHub Desktop.
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 { createSelector, createFeatureSelector } from '@ngrx/store'; | |
// <{ isLogin: boolean, errorMessage: string }>はstoreの型、reducerに書いたやつ | |
// 'LoginState'はキー。好きな名前でOK | |
export const selectFeature = createFeatureSelector<{ isLogin: boolean, errorMessage: string }>('LoginState'); | |
// getIsLoginというselectorを作成し、storeからisLoginを取得 | |
export const getIsLogin = createSelector( | |
selectFeature, | |
(state) => state.isLogin | |
); | |
// getErrorMessageというselectorを作成し、storeからerrorMessageを取得 | |
export const getErrorMessage = createSelector( | |
selectFeature, | |
(state) => state.errorMessage | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment