Skip to content

Instantly share code, notes, and snippets.

@Saissaken
Created September 12, 2018 17:17
Show Gist options
  • Save Saissaken/0529c6af90dee16a7ba5f24c947e77f8 to your computer and use it in GitHub Desktop.
Save Saissaken/0529c6af90dee16a7ba5f24c947e77f8 to your computer and use it in GitHub Desktop.
NGRX reducer approach TS
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