Created
May 14, 2019 16:52
-
-
Save peterbsmyth/46b74bc8faeef50884cc94c41aba65bb to your computer and use it in GitHub Desktop.
New ngrx Actions
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
/* | |
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 }>() | |
); | |
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'; | |
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