From 3a5f42780c7256561fc3346649d9c2505b85f474 Mon Sep 17 00:00:00 2001 From: Mike Ryan Date: Sat, 28 Mar 2020 20:16:29 -0500 Subject: [PATCH] 14-auth-selectors --- src/app/shared/state/auth.reducer.ts | 4 ++++ src/app/shared/state/index.ts | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/app/shared/state/auth.reducer.ts b/src/app/shared/state/auth.reducer.ts index e999aef..7c5b6d4 100644 --- a/src/app/shared/state/auth.reducer.ts +++ b/src/app/shared/state/auth.reducer.ts @@ -35,3 +35,7 @@ export const authReducer = createReducer( export function reducer(state: State | undefined, action: Action) { return authReducer(state, action); } + +export const selectGettingStatus = (state: State) => state.gettingStatus; +export const selectUser = (state: State) => state.user; +export const selectError = (state: State) => state.error; diff --git a/src/app/shared/state/index.ts b/src/app/shared/state/index.ts index 9cc57fe..0ccf4b6 100644 --- a/src/app/shared/state/index.ts +++ b/src/app/shared/state/index.ts @@ -3,15 +3,34 @@ import * as fromAuth from "./auth.reducer"; import * as fromBooks from "./books.reducer"; export interface State { + auth: fromAuth.State; books: fromBooks.State; } export const reducers: ActionReducerMap = { + auth: fromAuth.reducer, books: fromBooks.reducer }; export const metaReducers: MetaReducer[] = []; +/** + * Auth Selectors + */ +export const selectAuthState = (state: State) => state.auth; +export const selectGettingAuthStatus = createSelector( + selectAuthState, + fromAuth.selectGettingStatus +); +export const selectAuthUser = createSelector( + selectAuthState, + fromAuth.selectUser +); +export const selectAuthError = createSelector( + selectAuthState, + fromAuth.selectError +); + /** * Books Selectors */