Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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