Created
September 12, 2018 17:17
-
-
Save Saissaken/0529c6af90dee16a7ba5f24c947e77f8 to your computer and use it in GitHub Desktop.
NGRX reducer approach TS
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 { Action } from '@ngrx/store'; | |
import { IUser } from './user.model'; | |
export namespace UserActions { | |
export enum ActionTypes { | |
GET_USER_REQUEST = '[Welcome] Get User Request', | |
GET_USER_FAILURE = '[Welcome] Get User Failure', | |
GET_USER_SUCCESS = '[Welcome] Get User Success', | |
} | |
export class GetUserRequestAction implements Action { | |
public readonly type = ActionTypes.GET_USER_REQUEST; | |
constructor(public payload: { | |
userId: number, | |
}) { } | |
} | |
export class GetUserFailureAction implements Action { | |
public readonly type = ActionTypes.GET_USER_FAILURE; | |
constructor(public payload: { | |
error: string, | |
}) { } | |
} | |
export class GetUserSuccessAction implements Action { | |
public readonly type = ActionTypes.GET_USER_SUCCESS; | |
constructor(public payload: { | |
user: IUser | |
}) { } | |
} | |
export type Actions = | |
GetUserRequestAction | | |
GetUserFailureAction | | |
GetUserSuccessAction | |
; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment