-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IncomeApp] adding user to the store
- Loading branch information
Showing
10 changed files
with
103 additions
and
18 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import * as fromUI from './shared/ui.reducer'; | ||
import * as fromAuth from './auth/auth.reducer'; | ||
import { ActionReducerMap } from '@ngrx/store'; | ||
|
||
export interface AppState { | ||
ui: fromUI.State; | ||
auth: fromAuth.AuthState | ||
} | ||
|
||
export const appReducers: ActionReducerMap<AppState> = { | ||
ui: fromUI.UIReducer | ||
ui: fromUI.UIReducer, | ||
auth: fromAuth.AuthReducer | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Action } from '@ngrx/store'; | ||
import { User } from './user.model'; | ||
|
||
export const SET_USER = '[Auth] Set User'; | ||
|
||
export class SetUserAction implements Action { | ||
readonly type = SET_USER; | ||
constructor(public user: User){} | ||
} | ||
|
||
export type actions = SetUserAction; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as AuthActions from './auth.actions'; | ||
import { User } from './user.model'; | ||
|
||
export interface AuthState { user: User; } | ||
const initState: AuthState = { user: null }; | ||
|
||
export function AuthReducer(state = initState, action: AuthActions.actions): AuthState { | ||
switch (action.type) { | ||
case AuthActions.SET_USER: | ||
return { user: {...action.user} }; | ||
default: | ||
return state; | ||
} | ||
} |
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
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
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
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
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
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
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