Skip to content

Instantly share code, notes, and snippets.

@peterbsmyth
Created May 14, 2019 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterbsmyth/46b74bc8faeef50884cc94c41aba65bb to your computer and use it in GitHub Desktop.
Save peterbsmyth/46b74bc8faeef50884cc94c41aba65bb to your computer and use it in GitHub Desktop.
New ngrx Actions
/*
Read more: https://blog.angularindepth.com/ngrx-action-creators-redesigned-d396960e46da
Description: Alex Okrushko goes in detail on what makes this so good.
*/
import { createAction, props } from '@ngrx/store';
export const submit = createAction(
'[New Expense] submit',
props<{ expense: any }>()
);
export const submitComplete = createAction(
'[New Expense] submitComplete',
props<{ expense: any }>()
);
export const submitError = createAction(
'[New Expense] submitError',
props<{ error: any }>()
);
import { Action } from '@ngrx/store';
export enum ClientActionTypes {
ADD_CLIENT = '[Client] ADD_CLIENT',
ADD_CLIENT_COMPLETE = '[Client] ADD_CLIENT_COMPLETE',
ADD_CLIENT_ERROR = '[Client] ADD_CLIENT_ERROR',
}
export class AddClient implements Action {
readonly type = ClientActionTypes.ADD_CLIENT;
constructor(public payload: any) {}
}
export class AddClientComplete implements Action {
readonly type = ClientActionTypes.ADD_CLIENT_COMPLETE;
constructor(public payload: any) {}
}
export class AddClientError implements Action {
readonly type = ClientActionTypes.ADD_CLIENT_ERROR;
constructor(public payload: any) {}
}
export type ClientActions
= AddClient
| AddClientComplete
| AddClientError
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment