Created
June 1, 2019 23:32
-
-
Save peterbsmyth/5582a5670b5be498a15dddaec4af8c98 to your computer and use it in GitHub Desktop.
ngrx 8 createEffect
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'; | |
export const get = createAction( | |
'[Job] get' | |
); | |
export const getComplete = createAction( | |
'[Job] getComplete', | |
props<{ job: any }>() | |
); | |
export const getError = createAction( | |
'[Job] getError', | |
props<{ error: any }>() | |
); | |
export const saveOneFavorite = createAction( | |
'[Job] saveOneFavorite', | |
props<{ job: any }>() | |
); | |
export const saveOneFavoriteComplete = createAction( | |
'[Job] saveOneFavoriteComplete', | |
props<{ job: any }>() | |
); | |
export const saveOneFavoriteError = createAction( | |
'[Job] saveOneFavoriteError', | |
props<{ error: any }>() | |
); | |
export const select = createAction( | |
'[Job] select', | |
props<{ id: any }>() | |
); | |
export const filter = createAction( | |
'[Job] filter', | |
props<{ filter: 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 { Injectable } from '@angular/core'; | |
import { Actions, ofType, createEffect } from '@ngrx/effects'; | |
import { mapTo } from 'rxjs/operators'; | |
import { JobCodeActions } from '../actions'; | |
@Injectable() | |
export class JobCodeEffects { | |
get$ = createEffect(() => | |
this.actions$.pipe( | |
ofType(JobCodeActions.get), | |
mapTo(JobCodeActions.getComplete({ | |
jobCode: {} | |
})) | |
) | |
); | |
saveOneFavorite$ = createEffect(() => | |
this.actions$.pipe( | |
ofType(JobCodeActions.saveOneFavorite), | |
mapTo(JobCodeActions.saveOneFavoriteComplete({ | |
jobCode: {} | |
})) | |
) | |
); | |
constructor( | |
private actions$: Actions | |
) { } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment