Created
July 21, 2019 21:44
-
-
Save wesleygrimes/e6259eaab4b149f2d7f8d12e631a9518 to your computer and use it in GitHub Desktop.
NgRx v8 Higher-Order Action Creators
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 { createAction, props } from '@ngrx/store'; | |
import { Joke } from 'src/app/models'; | |
export const createJokeSuccessAction = (actionType: string) => | |
createAction(actionType, props<{ jokes: Joke[] }>()); | |
export const createJokeFailureAction = (actionType: string) => | |
createAction(actionType, props<{ error: any }>()); | |
export const loadAll = createAction('[Jokes Page] Load All'); | |
export const loadAllSuccess = createJokeSuccessAction( | |
'[Jokes API] Load All Success' | |
); | |
export const loadAllFailure = createJokeFailureAction( | |
'[Jokes API] Load All Failure' | |
); | |
export const loadCategory = createAction( | |
'[Jokes Page] Load Category', | |
props<{ category: string }>() | |
); | |
export const loadCategorySuccess = createJokeSuccessAction( | |
'[Jokes API] Load Category Success' | |
); | |
export const loadCategoryFailure = createJokeFailureAction( | |
'[Jokes API] Load Category Failure' | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment